a3b357abd89c781776329253790e60d56f78b883

Author
Bob Williams <bobwilliams.ii@gmail.com>
Committer
Phil Eichinger <phil@zankapfel.net>
Date

Message

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..51578b3493182c251c555a7b4d0950959fef5097
 4--- /dev/null
 5+++ b/plugins/jsontools/jsontools.plugin.zsh
 6@@ -0,0 +1,14 @@
 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 python) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xpython" ) ]]; then
15+	alias pp_json='python -mjson.tool'
16+elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xruby" ) ]]; then
17+	alias pp_json='ruby -e "require \"json\"; require \"yaml\"; puts JSON.parse(STDIN.read).to_yaml"'
18+fi
19+
20+unset JSONTOOLS_METHOD