add pst script for internal pastebin

This commit is contained in:
Daniel Lundin 2024-02-17 12:49:21 +01:00
parent 64d50a238b
commit c0e875a4eb

15
bin/pst Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
set -eo pipefail
URL="https://paste.aarn.shelman.io"
FILEPATH="$1"
FILENAME=$(basename -- "$FILEPATH")
EXTENSION="${FILENAME##*.}"
RESPONSE=$(curl -s --data-binary "@${FILEPATH:-/dev/stdin}" --url $URL)
PASTELINK="$URL$RESPONSE"
[ -z "$EXTENSION" ] &&
echo "$PASTELINK" ||
echo "$PASTELINK.$EXTENSION"