aboutsummaryrefslogtreecommitdiff
path: root/scripts/scripts/up
blob: 6b9ece4212d857a72f306e4efe951c6dcfca38a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash

id=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1 )

if [ $# != 1 ]; then
    echo "needs an arg"
else
    if [ -f "$1" ]; then
        ext="${1##*.}"
        id="$id.$ext"
        scp -P 22222 "$1" ferrn:~/www/nerd/uploads/"$id"
        echo "https://u.peppe.rs/$id"
        if hash xclip 2> /dev/null; then
            echo "https://u.peppe.rs/$id" | xclip -selection clipboard
            echo "https://u.peppe.rs/$id" | xclip -i
        fi
    else
        echo "file does not exist"
    fi
fi