Skip to content

Instantly share code, notes, and snippets.

@gwerbin
Created August 19, 2021 20:14
Show Gist options
  • Save gwerbin/7fd5ea262457c60fb682a09dcef381fd to your computer and use it in GitHub Desktop.
Save gwerbin/7fd5ea262457c60fb682a09dcef381fd to your computer and use it in GitHub Desktop.
#!/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