a TUI playground for exploring shell scripting.
This application is a fork of jqp, a TUI playground to experiment with jq.
Clone this repository, build from source with cd shp && go build, then move the binary to somewhere accessible in your PATH, e.g. mv ./shp /usr/local/bin.
➜ shp --help
shp is a terminal user interface (TUI) for exploring shell scripting.
You can use it to run shell scripts interactively. If no script is provided, the interface will prompt you for one.
The command accepts an optional script argument which will be executed against the input.
You can provide the input either through a file or via standard input (stdin).
Usage:
shp [script] [flags]
Flags:
--config string path to config file (default is $HOME/.jqp.yaml)
-f, --file string path to the input file
-h, --help help for shp
-s, --shell string interpreter to use (defaults to $SHELL, or /bin/sh if unset)
-t, --theme string jqp theme
-v, --version version for shp
shp also supports input from STDIN. STDIN takes precedence over the command-line flag. Additionally, you can pass an optional script argument to shp that it will execute upon loading.
➜ ps | shp 'tac | tee /dev/stderr | wc'
| Keybinding | Action |
|---|---|
tab |
cycle through sections |
shift-tab |
cycle through sections in reverse |
ctrl-y |
copy script to system clipboard1 |
ctrl-s |
save output to file (copy to clipboard if file not specified) |
ctrl-t |
toggle showing/hiding input panel |
ctrl-c |
quit program / kill long-running script |
| Keybinding | Action |
|---|---|
ctrl+r |
execute script |
↑/↓ |
cycle through script history |
ctrl-a |
go to beginning of line |
ctrl-e |
go to end of line |
←/ctrl-b |
move cursor one character to left |
→/ctrl-f |
move cursor one character to right |
ctrl-k |
delete text after cursor line |
ctrl-u |
delete text before cursor |
ctrl-w |
delete word to left |
ctrl-d |
delete character under cursor |
| Keybinding | Action |
|---|---|
↑/k |
up |
↓/j |
down |
ctrl-u |
page up |
ctrl-d |
page down |
shp can be configured with a configuration file. By default, shp uses the same configuration file of jqp and will search your home directory for a YAML file named .jqp.yaml. A path to a YAML configuration file can also be provided to the --config command-line flag.
➜ shp --config ~/my_jqp_config.yaml < data.jsonIf a configuration option is present in both the configuration file and the command-line, the command-line option takes precedence. For example, if a theme is specified in the configuration file and via -t/--theme flag, the command-line flag will take precedence.
theme:
name: "nord" # controls the color scheme
chromaStyleOverrides: # override parts of the chroma style
kc: "#009900 underline" # keys use the chroma short namesThemes can be specified on the command-line via the -t/--theme <themeName> flag. You can also set a theme in your configuration file.
theme:
name: "monokai"Overrides to the chroma styles used for a theme can be configured in your configuration file.
For the list of short keys, see chroma.StandardTypes. To see which token to use for a value, see the JSON lexer (look for <token> tags). To see the color and what's used in the style you're using, look for your style in the chroma styles directory.
theme:
name: "monokai" # name is required to know which theme to override
chromaStyleOverrides:
kc: "#009900 underline"You can change non-syntax colors using the styleOverrides key:
theme:
styleOverrides:
primary: "#c4b28a"
secondary: "#8992a7"
error: "#c4746e"
inactive: "#a6a69c"
success: "#87a987"Themes are broken up into light and dark themes. Light themes work best in terminals with a light background and dark themes work best in a terminal with a dark background. If no theme is specified or a non-existent theme is provided, the default theme is used, which was created to work with both terminals with a light and dark background.
abapalgolarduinoautumnborlandcatppuccin-lattecolorfulemacsfriendlygithubgruvbox-lighthrdarkigorlovelacemannimonokai-lightmurphyonesenterpriseparaiso-lightpastieperldocpygmentssolarized-lighttangotracvisual_studiovulcanxcode
averagebase16snazzycatppuccin-frappecatppuccin-macchiatocatppuccin-mochadoom-onedoom-one2draculafruitygithub-darkgruvboxmonokainativeparaiso-darkrrtsolarized-darksolarized-dark256swapoffvimwitchhazelxcode-dark
Footnotes
-
shpuses https://github.com/atotto/clipboard for clipboard functionality. Things should work as expected with OSX and Windows. Linux, Unix requirexcliporxselto be installed. ↩