home/bin/up (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#!/usr/bin/env bash gen_random() { chars="abcdefghijklmnopqrstuvwxyz0123456789-~" for i in { 1 .. 6 }; do printf '%s' "${chars:RANDOM%${#chars}:1}" done } random_name="$(gen_random)" export LATEST_SCROT="$HOME/pics/scrots/latest.png" upload() { file="$(basename "$1")" ext="${file##*.}" fullname="$random_name.$ext" rsync --archive --partial --progress --rsh=ssh "$1" fern:~/www/icy/uploads/"$fullname" printf '%s\n' "https://x.icyphox.sh/$fullname" if [ "$(uname)" != "Darwin" ]; then printf '%s' "https://x.icyphox.sh/$fullname" | xclip -selection clipboard else printf '%s' "https://x.icyphox.sh/$fullname" | pbcopy fi } if [ "$1" == "l" ]; then upload "$LATEST_SCROT" elif [ "$1" != "l" ]; then upload "$1" fi |