#!/usr/bin/env bash # Public Domain / CC0 uuid=$(uuidgen -r) tmpfile="$(mktemp)" edit=0 pasteclip=0 while getopts ":hecd:" x; do case $x in h) echo "vps-store [-e] [-c] [-d ID] [file]" exit ;; e) edit=1 ;; c) pasteclip=1 ;; d) ssh "VPS" "rm /usr/local/www/gopher/paste/$OPTARG" exit ;; esac opts=true done shift $(($OPTIND - 1)) if [ "$edit" -ne "0" ]; then "$EDITOR" "$tmpfile" file="$tmpfile" elif [ ! -z "$1" ]; then file="$1" else cat > $tmpfile file="$tmpfile" fi chmod 664 "$file" rsync -aH "$file" "VPS:/usr/local/www/gopher/paste/$uuid.txt" URL="http://gopher.wdj-consulting.com:70/paste/$uuid.txt" if [ "$pasteclip" -ne "0" ]; then if [ "$(expr substr $(uname -s) 1 10)" = "MINGW64_NT" ]; then echo "$URL" > /dev/clipboard else echo "$URL" | xclip -sel clip echo "$URL" | xclip fi fi echo "$URL" rm "$tmpfile"