From 29a481031d120a35708fb688531936233f2d2296 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Tue, 18 Apr 2017 18:16:14 +0200 Subject: [PATCH] Initial for `.fish` --- screenshot.fish | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 screenshot.fish diff --git a/screenshot.fish b/screenshot.fish new file mode 100644 index 0000000..d7329e4 --- /dev/null +++ b/screenshot.fish @@ -0,0 +1,31 @@ +# Setup +set SCP_USER "jmaa" +set SRT_USER "j" + +# Other stuff +set SCP_HOST "strawberry.thedevcave.net" +set SCP_PATH "~/public_html/screenshots" +set HTTP_URL "http://dcav.pw/$SRT_USER" + +if count $argv > /dev/null + set FILE_EXT $argv[2] + set TEMP_FILE $argv[1] +else + set FILE_EXT ".png" + set TEMP_FILE "/tmp/screenshot_temp"$FILE_EXT + scrot -rzu $TEMP_FILE +end + +set LINK (echo (sha256sum -b $TEMP_FILE) | xxd -r -p | base64 | cut -c-3) +set FILENAME $LINK$FILE_EXT + +if count $argv > /dev/null + set LINK $FILENAME +end + +if test $TEMP_FILE + echo $HTTP_URL$LINK | xclip -i -sel clip + scp $TEMP_FILE "$SCP_USER@$SCP_HOST:$SCP_PATH/$FILENAME" + rm $TEMP_FILE + echo "File accessable at '$HTTP_URL$LINK'" +end