diff options
| author | Sam Nystrom <sam@samnystrom.dev> | 2026-01-15 22:34:35 -0500 |
|---|---|---|
| committer | Sam Nystrom <sam@samnystrom.dev> | 2026-01-15 22:34:35 -0500 |
| commit | c40794b2040330ec2625bedf7df961115680c08b (patch) | |
| tree | 4ff1d4fda76d5d59d5d3604a015cc474438ab470 /bin/pastebin | |
| parent | 8fdacc55625a04f94d3e364d53aeec84bc93f6be (diff) | |
update bin
Diffstat (limited to 'bin/pastebin')
| -rwxr-xr-x | bin/pastebin | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/bin/pastebin b/bin/pastebin index 87d26cf..184b57a 100755 --- a/bin/pastebin +++ b/bin/pastebin @@ -1,7 +1,10 @@ #!/bin/sh -eu +base="https://0x0.st" +field="file" expires= -while getopts e:h opt; do + +while getopts e:u:f:h opt; do case "$opt" in e) if ! printf %d "$OPTARG" >/dev/null 2>&1; then @@ -10,13 +13,21 @@ while getopts e:h opt; do fi expires="$OPTARG" ;; + u) + base="$OPTARG" + ;; + f) + field="$OPTARG" + ;; h) cat <<-EOF Usage: ${0##*/} [-e EXPIRES] [FILE] -Upload FILE (or stdin) to envs.sh and print the URL +Upload FILE (or stdin) to a pastebin and print the URL -e EXPIRES Set the expiration time, either hours or epoch milliseconds + -u URL Provide a different pastebin (default: https://0x0.st) + -f FIELD Use a different field name for the file (default: file) EOF exit 0 ;; @@ -26,14 +37,17 @@ Upload FILE (or stdin) to envs.sh and print the URL ;; esac done + shift $((OPTIND-1)) + if [ $# -gt 1 ]; then printf 'Usage: %s [-e EXPIRES] [FILE]\n' "${0##*/}" exit 1 fi + file="${1:-/dev/stdin}" [ "$file" = '-' ] && file="/dev/stdin" -url="$(curl -fsS -F file=@"$file" ${expires:+-F expires="$expires"} https://envs.sh)" +url="$(curl -fsS -F "$field"=@"$file" ${expires:+-F expires="$expires"} "$base")" printf '%s\n' "$url" wl-copy "$url" |
