Skip to content

Instantly share code, notes, and snippets.

@meleu
Last active September 22, 2021 17:33
Show Gist options
  • Save meleu/41331f49da6ffe8623746eb4f604fede to your computer and use it in GitHub Desktop.
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)
# 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