all repos — dotfiles @ 46556b60d65b251332ea9340aca95659ec3adb6f

my *nix dotfiles

home/bin/up (view raw)

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