bin/cj: combine jq and bat

This commit is contained in:
xeruf 2022-08-30 15:22:16 +02:00
parent 936c4ab5e2
commit e023ff95e6
1 changed files with 2 additions and 2 deletions

View File

@ -4,7 +4,7 @@
set -o pipefail
# jq if file is valid json, otherwise show parseable lines with bat
unbuffer jq --unbuffered '' "$@" | less -F ||
{ jq --unbuffered '' "$@" ||
# add echo in case file is missing newline at the end
{ for arg; do echo "FILE: $arg ─────────────────────────────────────────────────────────────────────────────────────────"; cat "$arg"; done; echo; } |
while read -r line
@ -14,5 +14,5 @@ unbuffer jq --unbuffered '' "$@" | less -F ||
then echo "${line%,}" | python3 -m json.tool --no-ensure-ascii --sort-keys
else echo "$line"
fi
done | bat --language json --style numbers
done } | bat --language json --style numbers
#bat --language json --style plain --pager json-format "$@"