Created
August 19, 2021 20:14
-
-
Save gwerbin/7fd5ea262457c60fb682a09dcef381fd to your computer and use it in GitHub Desktop.
Requires ZSH (https://www.zsh.org/), cURL (https://curl.se/), and JQ (https://stedolan.github.io/jq/).
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
#!/usr/bin/env zsh | |
emulate zsh | |
setopt err_exit pipe_fail warn_create_global warn_nested_var no_unset | |
if (( ${#@} == 0 )); then | |
data="$(cat)" | |
elif (( ${#@} == 1)); then | |
case $1 in | |
-) data="$(cat)" ;; | |
*) data="$(cat $1)" ;; | |
esac | |
else | |
print -u2 'Too many arguments.' | |
exit 1 | |
fi | |
# TODO: handle other hosted Hastebin instances | |
# paste_domain="${PASTE_DOMAIN:-paste.pythondiscord.com}" | |
# base_url="https://${paste_domain%/*}" | |
base_url='https://paste.pythondiscord.com' | |
# setopt xtrace | |
curl --location --request POST "${base_url}/documents" --data "$data" \ | |
| jq -r "\"${base_url}/\"+.key" | |
# TODO: handle HTTP errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment