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
Oh My Zsh
Commits
40a9d9cb
Commit
40a9d9cb
authored
Aug 15, 2016
by
$ea
Committed by
Robby Russell
Aug 14, 2016
Browse files
plugins/urltools: add suport for python 3 (#5039)
Python 3!!!!
parent
b44aa61f
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/urltools/urltools.plugin.zsh
View file @
40a9d9cb
...
@@ -11,9 +11,12 @@ fi
...
@@ -11,9 +11,12 @@ fi
if
[[
$(
whence node
)
!=
""
&&
(
"x
$URLTOOLS_METHOD
"
=
"x"
||
"x
$URLTOOLS_METHOD
"
=
"xnode"
)
]]
;
then
if
[[
$(
whence node
)
!=
""
&&
(
"x
$URLTOOLS_METHOD
"
=
"x"
||
"x
$URLTOOLS_METHOD
"
=
"xnode"
)
]]
;
then
alias
urlencode
=
'node -e "console.log(encodeURIComponent(process.argv[1]))"'
alias
urlencode
=
'node -e "console.log(encodeURIComponent(process.argv[1]))"'
alias
urldecode
=
'node -e "console.log(decodeURIComponent(process.argv[1]))"'
alias
urldecode
=
'node -e "console.log(decodeURIComponent(process.argv[1]))"'
elif
[[
$(
whence python
)
!=
""
&&
(
"x
$URLTOOLS_METHOD
"
=
"x"
||
"x
$URLTOOLS_METHOD
"
=
"xpython"
)
]]
;
then
elif
[[
$(
whence python3
)
!=
""
&&
(
"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
urlencode
=
'python3 -c "import sys, urllib.parse as up; print(up.quote_plus(sys.argv[1]))"'
alias
urldecode
=
'python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"'
alias
urldecode
=
'python3 -c "import sys, urllib.parse as up; print(up.unquote_plus(sys.argv[1]))"'
elif
[[
$(
whence python2
)
!=
""
&&
(
"x
$URLTOOLS_METHOD
"
=
"x"
||
"x
$URLTOOLS_METHOD
"
=
"xpython"
)
]]
;
then
alias
urlencode
=
'python2 -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
alias
urldecode
=
'python2 -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
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
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
"
}
function
urldecode
()
{
printf
$(
echo
-n
$@
|
sed
's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g'
)
"
\n
"
}
...
...
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