dunkaroo Posted November 10, 2016 Posted November 10, 2016 (edited) I am having a little trouble to convert {query} to url encode characters, I found a solution from Stack Exchange https://askubuntu.com/questions/53770/how-can-i-encode-and-decode-percent-encoded-strings-on-the-command-line It works fine in the terminal alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"' alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"' echo "test special character +-*/=" | urlencode but when I edit and paste to "script" in Alfred workflow it fail to run alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"' alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"' echo "{query}" | urlencode The input node is "hotkey", "current selection from os" Thanks Edited November 10, 2016 by dunkaroo
deanishe Posted November 10, 2016 Posted November 10, 2016 Aliases don't work in non-interactive mode. Just pipe the input straight into the Python command: echo "{query}" | python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"
deanishe Posted November 12, 2016 Posted November 12, 2016 Come to think of it, that won't work. If you're piping in the input, you'd need: echo "{query}" | python -c "import sys, urllib as ul; print ul.quote_plus(sys.stdin.read())"
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now