aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_urlencode.fish
blob: ebf5ba5df2b92278686ef3fd8c6d0681608ed242 (plain)
1
2
3
4
5
6
7
8
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