8 ms·
I wrote a 10-line script to interactively query JSON documents using jq from vim in a tmux pane. Like jid[1], but better. Here it is: jq-repl () { local q
by psacawa 5y ago
I wrote a 10-line script to interactively query JSON documents using jq from vim in a tmux pane. Like jid[1], but better. Here it is:
jq-repl () {
local query_file json_file new_pane_height nodemon_cmd change_aucmd jq_args
query_file=$(mktemp)
json_file=${query_file}.json
cat /dev/stdin > $json_file
new_pane_height=5
jq_args="$@ -C -f $query_file $json_file"
nodemon_cmd="clear; jq $jq_args | less"
change_aucmd="au TextChanged,TextChangedI <buffer> write"
tmux split-window -l$new_pane_height $EDITOR -c "$change_aucmd" -c "set ft=jq" $query_file
nodemon -q -d 0.3 -w $query_file -x "$nodemon_cmd"
}
dependencies: vim, tmux, jq, nodemon
[1] https://github.com/simeji/jid https://github.com/simeji/jid