diff --git a/chezmoi/dot_zshrc.d/executable_jqi.zsh b/chezmoi/dot_zshrc.d/executable_jqi.zsh new file mode 100644 index 0000000..4283561 --- /dev/null +++ b/chezmoi/dot_zshrc.d/executable_jqi.zsh @@ -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"' + ) +}