all repos — dotfiles @ d59fbd2ea4d9ba33287b8b53ae0f69eb543f4ffb

my *nix dotfiles

nix/bin/up.nix (view raw)

 1{ pkgs, ... }:
 2let
 3  name = "up";
 4  xclip = "${pkgs.xclip}/bin/xclip";
 5in
 6pkgs.writeScriptBin name
 7  ''
 8    id=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 3 | head -n 1 )
 9
10    if [ $# != 1 ]; then
11        echo "needs an arg"
12    else
13        if [ -f "$1" ]; then
14            ext="''${1##*.}"
15            id="$id.$ext"
16            scp "$1" ferrn:~/www/nerd/uploads/"$id"
17            echo "https://u.peppe.rs/$id"
18            echo "https://u.peppe.rs/$id" | ${xclip} -selection clipboard
19            echo "https://u.peppe.rs/$id" | ${xclip} -i
20        else
21            echo "file does not exist"
22        fi
23    fi
24  ''