Define an interactive jq & fzf function: jqi
This commit is contained in:
parent
be7baeb322
commit
155f6e7b1f
1 changed files with 19 additions and 0 deletions
19
chezmoi/dot_zshrc.d/executable_jqi.zsh
Normal file
19
chezmoi/dot_zshrc.d/executable_jqi.zsh
Normal 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"'
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in a new issue