ffc17b6b4d55f74b9d3786ba790b7340865e5014
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #2563 from bobwilliams/master
Adds command line aliases useful for dealing with JSON
Diff
1diff --git a/plugins/jsontools/jsontools.plugin.zsh b/plugins/jsontools/jsontools.plugin.zsh
2new file mode 100644
3index 0000000000000000000000000000000000000000..7b6f8c585d8737a8314f8129e2aa5945fd2ba3d2
4--- /dev/null
5+++ b/plugins/jsontools/jsontools.plugin.zsh
6@@ -0,0 +1,16 @@
7+# JSON Tools
8+# Adds command line aliases useful for dealing with JSON
9+
10+if [[ $(whence $JSONTOOLS_METHOD) = "" ]]; then
11+ JSONTOOLS_METHOD=""
12+fi
13+
14+if [[ $(whence node) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xnode" ) ]]; then
15+ alias pp_json='node -e "console.log(JSON.stringify(process.argv[1]), null, 4)"'
16+elif [[ $(whence python) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xpython" ) ]]; then
17+ alias pp_json='python -mjson.tool'
18+elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xruby" ) ]]; then
19+ alias pp_json='ruby -e "require \"json\"; require \"yaml\"; puts JSON.parse(STDIN.read).to_yaml"'
20+fi
21+
22+unset JSONTOOLS_METHOD