diff options
author | Akshay <[email protected]> | 2021-09-26 16:56:36 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-09-26 16:56:36 +0100 |
commit | 5cdb4e421a809de51c3ebe8404e50d732721238b (patch) | |
tree | 73b71617c41b3e13edbf26035e821bb884d30441 /scripts/up.nix |
init
Diffstat (limited to 'scripts/up.nix')
-rw-r--r-- | scripts/up.nix | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/up.nix b/scripts/up.nix new file mode 100644 index 0000000..c4f7c7a --- /dev/null +++ b/scripts/up.nix | |||
@@ -0,0 +1,24 @@ | |||
1 | { pkgs, ... }: | ||
2 | let | ||
3 | name = "up"; | ||
4 | xclip = "${pkgs.xclip}/bin/xclip"; | ||
5 | in | ||
6 | pkgs.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 | '' | ||