Skip to content

Instantly share code, notes, and snippets.

@b0o b0o/.zshrc
Created Jul 11, 2018

Embed
What would you like to do?
rawurlencode() {
local string="$@"
local strlen=${#string}
local encoded=""
local pos c o
for (( pos=0 ; pos<strlen ; pos++ )); do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9] ) o="${c}" ;;
* ) printf -v o '%%%02x' "'$c"
esac
encoded+="${o}"
done
echo "${encoded}"
}
h() {
local u="$(rawurlencode "$@")"
unbuffer curl "https://cheat.sh/$u" | less
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.