tb-dotfiles/chezmoi/dot_zshrc.d/executable_jqi.zsh
2022-05-13 12:30:58 -04:00

19 lines
306 B
Bash

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"'
)
}