summaryrefslogtreecommitdiff
path: root/plugins/urltools
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2013-12-02 23:39:26 -0800
committerRobby Russell <robby@planetargon.com>2013-12-02 23:39:26 -0800
commit2f3bddccfb4daac3dbaa7be2dd19fb6aaa7f09ce (patch)
tree8372c39cea8e3ba2d02695e8fc606ff71b00e8e3 /plugins/urltools
parent027c9ee4cd049c36eea2478fbb876cfac95d2e97 (diff)
parentc164f2aab693f4b32c209cb34784818fba434b2d (diff)
downloadzsh-2f3bddccfb4daac3dbaa7be2dd19fb6aaa7f09ce.tar.gz
zsh-2f3bddccfb4daac3dbaa7be2dd19fb6aaa7f09ce.tar.bz2
zsh-2f3bddccfb4daac3dbaa7be2dd19fb6aaa7f09ce.zip
Merge pull request #1931 from dongweiming/update-urltools
Add shell built method
Diffstat (limited to 'plugins/urltools')
-rw-r--r--plugins/urltools/urltools.plugin.zsh5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugins/urltools/urltools.plugin.zsh b/plugins/urltools/urltools.plugin.zsh
index 4ddfff8ce..22327334d 100644
--- a/plugins/urltools/urltools.plugin.zsh
+++ b/plugins/urltools/urltools.plugin.zsh
@@ -14,6 +14,9 @@ if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD
elif [[ $(whence python) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"'
+elif [[ $(whence xxd) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xshell" ) ]]; then
+ function urlencode() {echo $@ | tr -d "\n" | xxd -plain | sed "s/\(..\)/%\1/g"}
+ function urldecode() {printf $(echo -n $@ | sed 's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g')"\n"}
elif [[ $(whence ruby) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xruby" ) ]]; then
alias urlencode='ruby -r cgi -e "puts CGI.escape(ARGV[0])"'
alias urldecode='ruby -r cgi -e "puts CGI.unescape(ARGV[0])"'
@@ -33,4 +36,4 @@ elif [[ $(whence perl) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHO
fi
fi
-unset URLTOOLS_METHOD \ No newline at end of file
+unset URLTOOLS_METHOD