functions.zsh: add flexibility to upload()

This commit is contained in:
surtur 2022-10-18 13:48:43 +02:00
parent cb1e721073
commit 26089f154f
Signed by: wanderer
SSH Key Fingerprint: SHA256:MdCZyJ2sHLltrLBp0xQO0O1qTW9BT/xl5nXkDvhlMCI

@ -15,16 +15,17 @@ upload() {
# make eternity the default lifespan
FILE_LIFESPAN=${2:-e}
FILE_ID=$(base64 /dev/urandom | tr -d '/+' | dd bs=16 count=1 2>/dev/null)
FILENAME=$(basename $1)
rsync -auvP -4 $1 nebula:/var/www/htdocs/dotya.ml/files/$FILE_LIFESPAN/$FILE_ID-$1
rsync -auvP -4 $1 "nebula:/var/www/htdocs/dotya.ml/files/$FILE_LIFESPAN/$FILE_ID-$FILENAME"
FILE_URL="https://dotya.ml/files/$FILE_LIFESPAN/$FILE_ID-$1"
FILE_URL="https://dotya.ml/files/$FILE_LIFESPAN/$FILE_ID-$FILENAME"
if [[ -z "$WAYLAND_DISPLAY" ]]; then
echo $FILE_URL | xclip -selection clipboard
echo $FILE_URL | xsel --clipboard --input
else
echo $FILE_URL | wl-copy
wl-copy --trim-newline $FILE_URL
fi
echo $FILE_URL