Created
July 11, 2018 07:43
-
-
Save b0o/41ff38f4b083fd9f0353824d0df5b485 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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