56babe6538450f85ac2e8ef3dd04bf1654c46d75
- Author
- Bob Williams <bobwilliams.ii@gmail.com>
- Committer
- Bob Williams <bobwilliams.ii@gmail.com>
- 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