Live data from Hacker News

PJSON: pretty, colorful json output formatting for terminal

igorgue.com

31–36 of 36 posts

Re: PJSON: pretty, colorful json output formatting for terminal

#31
post #7
post #3

Wait wait ... what are the unicode characters for that cloud and lightning bolt? That looks awesome.

Author here, unfortunately no thunder on Mountain Lion :( [1] 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] http://wiki.xkcd.com/irc/Heart_Thunder

> The thunder lights up when the program doesn't end property (return 0).

Inspired! Did you come up with that part?

Re: PJSON: pretty, colorful json output formatting for terminal

#32
post #31
post #7

Earlier quoted context omitted.

Author here, unfortunately no thunder on Mountain Lion :( [1] 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] http://wiki.xkcd.com/irc/Heart_Thunder

> The thunder lights up when the program doesn't end property (return 0). Inspired! Did you come up with that part?

Haha yes.

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%})"
    }

Re: PJSON: pretty, colorful json output formatting for terminal

#33

Earlier quoted context omitted.

And Perl's JSON::XS echo '{"hello":"there"}' | json_xs

Or for pretty colors, try Data::Printer echo '{"hello":"there"}' | perl -MJSON -MDDP -E '$f = decode_json readline; p $f'

Is there a colored JSON dumper in Perl?

Re: PJSON: pretty, colorful json output formatting for terminal

#34

alias pjson='pygmentize -l json'

I'm curious how the author managed to learn the pygments library without learning it already provided a command. This script can be replaced by

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

Re: PJSON: pretty, colorful json output formatting for terminal

#35
post #6

If this is based on pygments, is it reasonable to have a command like this that works on everything pygments knows how to highlight, and plugs into a bunch of pretty-printers / reformatters, e.g. GNU indent? Is there an equivalent of pygments for pretty-printing all the things?

http://pygments.org/docs/cmdline/
Post reply on HN