dotfiles/.bin/OLD/dopaste

33 lines
828 B
Plaintext
Raw Normal View History

2022-12-06 08:01:44 +01:00
#!/bin/sh
. $HOME/.bin/_config
RPATH=/home/sdk/make-web/src/paste
SSH="sdk@home.codevoid.de"
WEB="https://ptrace.org"
2022-12-06 08:01:44 +01:00
f="$1"
if [ "$1" = "-h" ]; then
printf "Usage:\n"
printf " paste < text.txt - read from stdin, generate filename\n"
printf " paste new.txt < file.txt - read from stdin with filename\n"
printf " paste file.txt - upload file as is\n"
return 0
fi
if [ -z "$1" ]; then
f="$(date +"%Y-%m-%d_%M-%S")-$(pwgen -1 4 -A -0).txt"
ssh ${SSH} "printf \"%s\" \"$(cat)\" > ${RPATH}/$f"
2022-12-06 08:01:44 +01:00
elif [ -f "$f" ]; then
scp "$f" ${SSH}:"${RPATH}/${f##*/}"
2022-12-06 08:01:44 +01:00
else
ssh ${SSH} "printf \"%s\n\" \"$(cat)\" > ${RPATH}/${f##*/}"
2022-12-06 08:01:44 +01:00
fi
ssh ${SSH} "cd ~/make-web && make install"
2022-12-06 08:01:44 +01:00
printf "${WEB}/${f##*/}\n"
printf "${WEB}/${f##*/}" | xclip
2022-12-06 08:01:44 +01:00
[ -z $DISPLAY ] || notify-send "$(xclip -o)"