Use fancy aliases to reformat markup
Looking at serialized data? I use a combination of tools and fancy shell aliases to make this easier:
Install a couple of tools:
- Make sure you have python
- Pygments (python lib)
- Libxml2 (to get xmllint)
Then add your aliases to your (zsh|bash)rc file (I use xp for XML Print and jp for JSON Print):
# JSON Print
alias jp="python -mjson.tool | pygmentize -f terminal256 -O style=native -g |less -r"
# XML Print
alias xp="xmllint --recover --format - | pygmentize -f terminal256 -O style=native -g |less -r"
Then enjoy browsing your serialized data all prettied up from the command-line:
# Yer JSON is Perrty
curl -XGET -H "Content-Type:application/json" http://<some url>.json | jp
# Yer XML is Perrty
curl -XGET -H "Content-Type:application/xml" http://<some url> | xp
Adapted from an SO answer
Written by Aaron Spiegel
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Zsh
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#