jsontools.plugin.zsh 713 B

12345678910111213141516
  1. # JSON Tools
  2. # Adds command line aliases useful for dealing with JSON
  3. if [[ $(whence $JSONTOOLS_METHOD) = "" ]]; then
  4. JSONTOOLS_METHOD=""
  5. fi
  6. if [[ $(whence node) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xnode" ) ]]; then
  7. alias pp_json='node -e "console.log(JSON.stringify(process.argv[1]), null, 4)"'
  8. elif [[ $(whence python) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xpython" ) ]]; then
  9. alias pp_json='python -mjson.tool'
  10. elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xruby" ) ]]; then
  11. alias pp_json='ruby -e "require \"json\"; require \"yaml\"; puts JSON.parse(STDIN.read).to_yaml"'
  12. fi
  13. unset JSONTOOLS_METHOD