Last Updated: February 25, 2016
·
1.979K
· natfriedman

Quick screenshot sharing

I use this script at least 20 times a day. It sits in the dock on my mac, and I use to quickly screenshot a region of the screen, copy it to my server, and put the URL for the screenshot in my paste buffer. Click, drag, Cmd-v. It's faster than any of the commercial alternatives I've found. It generates a random, non-guessable URL.

#!/bin/sh

SCP_USER='nat'
SCP_HOST='nat.org'
SCP_PATH='/path/to/web/files/nat.org/x/'

HTTP_URL="http://nat.org/x/"

FILENAME=`(cat /dev/random|head -c 10; date) | md5 -q | head -c 10`.png
FILEPATH=/tmp/$FILENAME

screencapture -i $@ $FILEPATH
if [ -f $FILEPATH ]
then
    echo $HTTP_URL$FILENAME | pbcopy
    scp $FILEPATH ${SCP_USER}@${SCP_HOST}:$SCP_PATH
    rm $FILEPATH

    echo `date` $HTTP_URL$FILENAME >> ~/bin/sattap.log
fi

4 Responses
Add your response

Great little app, will definitely use, slight tweak use
sshpass -p ${SCP_PASS}

add this prior to scp and add the SCP_PASS variable.

over 1 year ago ·

Gist if anyone likes my addition
https://gist.github.com/davesherratt/5488862

over 1 year ago ·

I thought of an adaptation for linux/ubuntu:
* replace "screencapture" by "scrot"
* use /dev/urandom instead of /dev/random
* md5 doesn't exist as is, must 'awk' md5sum a little, or use some other scripting

https://gist.github.com/bobmaerten/5489254

over 1 year ago ·

Reminds me of this: http://grabbox.devsoft.no/ integrates with the normal screen shot hot key on OS X, drops the image in dropbox, and puts the public link in your paste buffer.

over 1 year ago ·