bin/cj: combine jq and bat
This commit is contained in:
parent
936c4ab5e2
commit
e023ff95e6
|
@ -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 "$@"
|
||||
|
|
Loading…
Reference in New Issue