dotfiles/.local/bin/scripts/json-format

11 lines
313 B
Plaintext
Raw Normal View History

2022-08-30 13:19:41 +00:00
#!/bin/sh -e
# Format json as bat pager with python json.tool
while read -r line
do
echo $line | bat -A
line="$(echo ${line% } | sed "s|.*\[0m\(.*\)|\1|")"
echo $line | bat -A
command expr length "$line" \> 2 &&
echo "${line%,}" | python3 -m json.tool --no-ensure-ascii --sort-keys
done