6 ms·
PJSON: pretty, colorful json output formatting for terminal
- diegogomes 14y ago#cool
- maratd 14y agoWait wait ... what are the unicode characters for that cloud and lightning bolt? That looks awesome.
- JoshTriplett 14y agoThanks to gucharmap's excellent Unicode character search: ☁ U+2601 CLOUD ⚡ U+26A1 HIGH VOLTAGE SIGN
- mburns 14y agoIt is the cloud theme of Oh-my-zsh. https://github.com/robbyrussell/oh-my-zsh/wiki/themes https://github.com/robbyrussell/oh-my-zsh/wiki/themes
- igorgue 14y agoAuthor here, unfortunately no thunder on Mountain Lion :( [1] It's from my zsh theme: https://raw.github.com/igorgue/oh-my-zsh/master/themes/igorgue.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 http://wiki.xkcd.com/irc/Heart_Thunder
- ZoFreX 14y ago> The thunder lights up when the program doesn't end property (return 0). Inspired! Did you come up with that part?
- igorgue 14y agoHaha 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%})" }
- zokier 14y agoThere is unicode characters (code points, graphemes, whatevs) for everything http://unicodesnowmanforyou.com/ http://unicodesnowmanforyou.com/
- geofft 14y agoIf 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?
- nigma 14y agoHere's a similar trick with the Python json module: echo '{"hello":"there"}' | python -mjson.tool
- oylenshpeegul 14y agoAnd Perl's JSON::XS echo '{"hello":"there"}' | json_xs
- oylenshpeegul 14y agoOr for pretty colors, try Data::Printer echo '{"hello":"there"}' | perl -MJSON -MDDP -E '$f = decode_json readline; p $f'
- harbud 14y agoIs there a colored JSON dumper in Perl?
- lttlrck 14y agoyeah that's mentioned on the second line of TFA
- ericmoritz 14y agodang 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!
- bryanlarsen 14y agomany more options here: http://stackoverflow.com/questions/352098/how-to-pretty-print-json-script http://stackoverflow.com/questions/352098/how-to-pretty-prin...
- benatkin 14y agoThis here is my favorite. http://stackoverflow.com/a/6066102/3461 http://stackoverflow.com/a/6066102/3461
- michaelmior 14y agoalias pjson='pygmentize -l json'
- sciurus 14y agoI'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
- RealCasually 14y agoWe recently discussed underscore-cli here on Hacker News (http://news.ycombinator.com/item?id=4491058 http://news.ycombinator.com/item?id=4491058) and I find it to offer more than this, but still a nice tool. https://github.com/ddopson/underscore-cli https://github.com/ddopson/underscore-cli
- axiak 14y agoWhy all of that complicated setup? Why not just support pip install pjson? :)
- xster 14y agoagreed, needs to be submitted to pypi now!
- Anm 14y ago"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.
- void-star 14y agoI'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.
- marksands07 14y agoHey kids, why shouldn't every python tool have a Ruby counterpart? :) https://github.com/marksands/pjson-rb https://github.com/marksands/pjson-rb
- igorgue 14y agoThis is awesome :)
- zgryw 14y agoCome on, you should use coderay instead of pygments. 100% ruby ;)
- marksands07 14y agoSweet! I went with a quick conversion rather than doing any research. Thanks for the link, I'll definitely give it a whirl tomorrow evening.
- petepete 14y agoThis 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 https://github.com/jkbr/httpie
- Argorak 14y agoFor those that want to stay in Ruby land: $ gem install jazor coderay $ echo '{"foo": "bar"}' | jazor | coderay -json
- chipaca 14y agoNot sure what this offers over what I currently have in ~bin with a similar name, python -m json.tool "$@" | pygmentize -l json | less -RSNFX
- mazlix 14y agooh man.. I was looking for exactly this earlier today.. it looks REALLY pretty