Skip to content

Instantly share code, notes, and snippets.

@KShivendu
Last active April 21, 2024 08:16
Show Gist options
  • Save KShivendu/666e0dcf36df1c802bafae26d70982e7 to your computer and use it in GitHub Desktop.
Save KShivendu/666e0dcf36df1c802bafae26d70982e7 to your computer and use it in GitHub Desktop.
jf: TUI for exploring JSON data
# jq REPL (jq + fzf = jf)
function jf() {
if [ $# -eq 0 ]; then
# pipe input
tempfile=$(mktemp)
cat > "$tempfile"
echo '' | fzf --print-query --preview "jq {q} $tempfile"
rm "$tempfile"
else
# filename arg input
echo '' | fzf --print-query --preview "jq {q} $1"
fi
}
@KShivendu
Copy link
Author

KShivendu commented Apr 21, 2024

Installation:

Bash:

curl https://gist.githubusercontent.com/KShivendu/666e0dcf36df1c802bafae26d70982e7/raw/0f2e812b542f75dd3421ad719a6696a15f19051c/jf.sh >> ~/.bashrc

Zsh:

curl https://gist.githubusercontent.com/KShivendu/666e0dcf36df1c802bafae26d70982e7/raw/0f2e812b542f75dd3421ad719a6696a15f19051c/jf.sh >> ~/.zshrc

Usage:

curl example.com/file.json | jf
jf file.json
# This will give TUI so you can explore JSON data in your terminal using JSONPath:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment