Define an interactive jq & fzf function: jqi

This commit is contained in:
Tony Blyler 2022-05-13 12:30:58 -04:00
parent be7baeb322
commit 155f6e7b1f

View file

@ -0,0 +1,19 @@
function jqi() {
(
set -euo pipefail
if [ "${1:--}" = "-" ]; then
INPUT="$(mktemp)"
trap 'rm -f "$INPUT"' EXIT
> "$INPUT"
else
INPUT="$1"
fi
export INPUT
echo | fzf --phony \
--preview-window='up:90%' \
--print-query \
--preview 'jq --color-output -r {q} "$INPUT"'
)
}