35 comments

[ 7.3 ms ] story [ 69.5 ms ] thread
Wait wait ... what are the unicode characters for that cloud and lightning bolt? That looks awesome.
Thanks to gucharmap's excellent Unicode character search:

☁ U+2601 CLOUD

⚡ U+26A1 HIGH VOLTAGE SIGN

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] <3 thunder 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%})"
    }
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?

(comment deleted)
Yes, it's the "pygmentize" command, included in pygments. Also, pygments is a fantastic tool, I love it.
Here's a similar trick with the Python json module:

  echo '{"hello":"there"}' | python -mjson.tool
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?
yeah that's mentioned on the second line of TFA
dang and all this time I've been doing this all this time:

   echo '{"hello": "there"}' | python -c "import json, sys; print json.dumps(json.load(sys.stdin), indent=4)"
Thanks for the tip!
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

Why all of that complicated setup? Why not just support pip install pjson? :)
agreed, needs to be submitted to pypi now!
"Small retina display images are fucking huge."

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.

I've been using json_reformat which comes from "yajl" to do this sort of thing for a while.

EDIT: I love seeing something that does an "awesome-print" with terminal colorization, though.

Hey kids, why shouldn't every python tool have a Ruby counterpart? :) https://github.com/marksands/pjson-rb
Come on, you should use coderay instead of pygments. 100% ruby ;)
Sweet! I went with a quick conversion rather than doing any research. Thanks for the link, I'll definitely give it a whirl tomorrow evening.
This looks really good, thanks.

Rather than pipe curl's output through stuff though, for the most part I use httpie [1]. It's a human-friendly curl wrapper.

[1] https://github.com/jkbr/httpie

For those that want to stay in Ruby land:

$ gem install jazor coderay

$ echo '{"foo": "bar"}' | jazor | coderay -json

Not sure what this offers over what I currently have in ~bin with a similar name,

python -m json.tool "$@" | pygmentize -l json | less -RSNFX

oh man.. I was looking for exactly this earlier today.. it looks REALLY pretty