PJSON: pretty, colorful json output formatting for terminal
igorgue.com
igorgue.com
Is there an equivalent of pygments for pretty-printing all the things?
echo '{"hello":"there"}' | python -mjson.tool echo '{"hello":"there"}' | json_xs echo '{"hello":"there"}' | perl -MJSON -MDDP -E '$f = decode_json readline; p $f' echo '{"hello": "there"}' | python -c "import json, sys; print json.dumps(json.load(sys.stdin), indent=4)"
Thanks for the tip!☁ U+2601 CLOUD
⚡ U+26A1 HIGH VOLTAGE SIGN
It's from my zsh theme: https://raw.github.com/igorgue/oh-my-zsh/master/themes/igorg... I stole it from the cloud theme and another theme that I don't remember.
The thunder lights up when the program doesn't end property (return 0).
[1] <3 thunder http://wiki.xkcd.com/irc/Heart_Thunder
Inspired! Did you come up with that part?
This is the code add it at the end of your prompt:
function thunder() {
echo "%(?,%{$fg_bold[grey]%}⚡%{$reset_color%},%{$fg_bold[yellow]%}⚡%{$reset_color%})"
}Rather than pipe curl's output through stuff though, for the most part I use httpie [1]. It's a human-friendly curl wrapper.
EDIT: I love seeing something that does an "awesome-print" with terminal colorization, though.
Even when reshown on retina displays, since the HTML standard is to attend to the pixel size and not the physical resolution. Screenshots taken with the standard Cmd-Shift-4 or similar all include proper resolution metadata, should someone want to show it at the correct size.
alias pjson='pygmentize -l json'
If you're passing it the file name, pygmentize will figure out the lexer to use, e.g.
pygmentize foo.json
pygmentize bar.rb
It's only when you have it read from stdin that you need to specify, e.g.
pygmentize -l json < foo.json
python -m json.tool "$@" | pygmentize -l json | less -RSNFX
$ gem install jazor coderay
$ echo '{"foo": "bar"}' | jazor | coderay -json