-
-
Save meleu/41331f49da6ffe8623746eb4f604fede to your computer and use it in GitHub Desktop.
upload a file to 0x0 (give an URL as argument and it acts as an URL shortener)
This file contains hidden or 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
# 0x0(): Upload file or URL shortener. See more info at https://0x0.st/ | |
0x0() { | |
local arg="$1" | |
local curlArg | |
if [[ -f "${arg}" ]]; then | |
curlArg="file=@${arg}" | |
elif [[ ${arg} =~ ^https?://.* ]]; then | |
curlArg="shorten=${arg}" | |
else | |
echo "error: '${arg}': invalid argument (not a file neither a URL)" >&2 | |
return 1 | |
fi | |
curl -F"${curlArg}" https://0x0.st | |
} | |
[[ "$0" == "$BASH_SOURCE" ]] && 0x0 "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment