From 155f6e7b1f4094e0d0e663483f6d19e9a55cd832 Mon Sep 17 00:00:00 2001 From: Tony Blyler Date: Fri, 13 May 2022 12:30:58 -0400 Subject: [PATCH] Define an interactive jq & fzf function: jqi --- chezmoi/dot_zshrc.d/executable_jqi.zsh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 chezmoi/dot_zshrc.d/executable_jqi.zsh 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"' + ) +}