Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
2f3bddcc
Commit
2f3bddcc
authored
Dec 02, 2013
by
Robby Russell
Browse files
Merge pull request #1931 from dongweiming/update-urltools
Add shell built method
parents
027c9ee4
c164f2aa
Changes
1
Show whitespace changes
Inline
Side-by-side
plugins/urltools/urltools.plugin.zsh
View file @
2f3bddcc
...
...
@@ -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])"'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment