all repos — dotfiles @ 4ca050a4d5afdcd0692a8f4857b24b9e2d4b0658

my *nix dotfiles

bin/up.nix (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
{ pkgs, ... }:
let
  name = "up";
  xclip = "${pkgs.xclip}/bin/xclip";
in
pkgs.writeScriptBin name
  ''
    id=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 3 | head -n 1 )

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