A de-minifier (formatter, exploder, beautifier) for shell one-liners.
sol [ sohl ] noun
sol
, I had no idea what the h**k that one-liner I got from Oscar was supposed to do.sol
first.sol
.sol
is an free open-source project, but I take dollars and even sols as tips.xargs
, parallel
) and formats those, toogo install -v github.com/noperator/sol/cmd/sol@latest
𝄢 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
Explode a complex one-liner directly on an interactive shell prompt. Great for iteratively editing a complex command.
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'
Invoke it directly within Vim using visual block mode, a custom keybinding, etc.
Alternatively, you can simply pipe a one-liner into standard input.
exec.Command
calls in shellenv.go
bash
This project is licensed under the MIT License.