jq zsh plugin
Interactively build jq expressions (gojq is also supported).
This zsh plugin gives you jq superpowers!
Fish users: you can use this friendly fork: rmartine-ias/jq-fish-plugin
Besides jq, this plugin also requires fzf (a recent version) to be installed and available on your PATH.
The following installation methods are proven to work:
git clone https://github.com/reegnz/jq-zsh-plugin.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/jq
~/.zshrc
):plugins=(
# other plugins...
jq
)
zplug reegnz/jq-zsh-plugin
antigen bundle reegnz/jq-zsh-plugin
zgen load reegnz/jq-zsh-plugin
Bringing up the jq query builder for a shell command: alt + j
During interactive querying, the following shortcuts can be used:
Shortcut | Effect |
---|---|
up |
Navigate path queries |
down |
Navigate path queries |
tab |
Select path query |
shift + up |
Scroll up |
shift + down |
Scroll down |
alt + up |
Scroll up full page |
alt + down |
Scroll down full page |
ctrl+r |
Reload input |
If you want to use an alternative jq
implementation, like
gojq then you can override the default jq
command used by the plugin. Set the following environment variable:
JQ_REPL_JQ=gojq
The project consists of the following components:
jq.plugin.zsh
providing a user-defined zsh line-editor
widget,
utilizing the jq-repl
commandjq-repl
command to interactively build jq expressions, utilizing fzf for
its UIjq-paths
command to get all valid jq paths in the provided JSON document,
used for suggesting paths.∆
symbol in iTerm2You need to remap your alt-key to Esc+
in iTerm2:
Cmd + ,
to enter preferencesEsc+
See other suggestions on stackoverflow if the above one doesn't help you: https://stackoverflow.com/q/196357/205318
Another option is to map to ctrl+j
instead by putting this in your .zshrc
:
bindkey `^j` jq-complete
The plugin automatically expands shell aliases in a command before passing it
to jq-repl
. To disable, put the following line into your .zshrc
:
JQ_ZSH_PLUGIN_EXPAND_ALIASES=0