Home

Awesome

sol

A de-minifier (formatter, exploder, beautifier) for shell one-liners.

<p align="center"> <img alt="ray" src="https://i.imgur.com/HfU0Y5X.png" width="700px"> </p>

sol [ sohl ] noun

  1. a tool to help you inspect chained shell commands before you share a one-liner (or after you receive one)<br> Before I ran sol, I had no idea what the h**k that one-liner I got from Oscar was supposed to do.
  2. (also soul) the spiritual part of humans regarded in its moral aspect<br> You probably don't have a soul—or at least, not a good one—if you share a one-liner with me without cleaning it up with sol first.
  3. (rude slang) in a hopeless position or situation<br> You're SOL if you think I'm going to try to read your one-liner without using sol.
  4. an old French coin equal to 12 deniers<br> sol is an free open-source project, but I take dollars and even sols as tips.

Features

Built with

Getting started

Install

go install -v github.com/noperator/sol/cmd/sol@latest

Usage

𝄢 sol -h
Usage of sol:
  -a	arguments
  -all
    	all
  -b	binary commands: &&, ||, |, |&
  -c	command substitution: $(), ``
  -e	inspect env to resolve command types
  -f string
    	file
  -j	jq
  -jqarr
    	arrays
  -jqobj
    	objects
  -jqop string
    	operators (comma-separated)
  -l	clauses: case, for, if, while
  -o	one line
  -p	process substitution: <(), >()
  -r	redirect: >, >>, <, <>, <&, >&, >|, <<, <<-, <<<, &>, &>>
  -s	shell strings: xargs, parallel
  -v	verbose

via CLI

Explode a complex one-liner directly on an interactive shell prompt. Great for iteratively editing a complex command.

cli

In the example above, I'm using bash in vi mode; I've bound @ to sol-func which calls sol with a few preset options.

sol-func() {
	local current_line="${READLINE_LINE}"
	READLINE_LINE=$(echo "$current_line" | sol -p -c -b -r -a -s -jqobj -jqarr -jqop comma)
	READLINE_POINT=${#READLINE_LINE}
}
bind -m vi-command -x '"@": sol-func'

via Vim

Invoke it directly within Vim using visual block mode, a custom keybinding, etc.

vim

via stdin

Alternatively, you can simply pipe a one-liner into standard input.

stdin

Back matter

See also

To-do

License

This project is licensed under the MIT License.