From 04c0ac9ee838bd455d620aa71c5c6642ba973e75 Mon Sep 17 00:00:00 2001 From: Tim Cuthbertson Date: Sat, 24 Aug 2013 18:16:16 +1000 Subject: add __fish_urlencode function which URL-escapes stdin --- share/functions/__fish_urlencode.fish | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 share/functions/__fish_urlencode.fish 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 -- cgit v1.2.3