aboutsummaryrefslogtreecommitdiffhomepage
path: root/share
diff options
context:
space:
mode:
authorGravatar Tim Cuthbertson <tim@gfxmonk.net>2013-08-24 18:16:16 +1000
committerGravatar Konrad Borowski <glitchmr@myopera.com>2013-09-04 20:30:42 +0200
commit04c0ac9ee838bd455d620aa71c5c6642ba973e75 (patch)
tree58cbe0359eded5d769c9881ccf4e7d98663695e2 /share
parent8159f55243e79f7107c09047e7d6b9e36f6ababf (diff)
add __fish_urlencode function which URL-escapes stdin
Diffstat (limited to 'share')
-rw-r--r--share/functions/__fish_urlencode.fish9
1 files changed, 9 insertions, 0 deletions
diff --git a/share/functions/__fish_urlencode.fish b/share/functions/__fish_urlencode.fish
new file mode 100644
index 00000000..ebf5ba5d
--- /dev/null
+++ b/share/functions/__fish_urlencode.fish
@@ -0,0 +1,9 @@
+function __fish_urlencode --description "URL-encode stdin"
+ while read f
+ set lines (echo "$f" | sed -E -e 's/./\n\\0/g;/^$/d;s/\n//')
+ if [ (count $lines) -gt 0 ]
+ printf '%%%02x' "'"$lines"'" | sed -e 's/%2[fF]/\//g';
+ end
+ end
+ echo
+end