Auto-Uploading Screenshots in OS X
Sunday, August 8th, 201099% of time I take a screenshot, its to show someone. The workflow there is:
- Take a screenshot of a selected area with Cmd+Shift+4. OS X saves it to the Desktop.
- Open a terminal.
- SCP the file to my web directory.
- Open the web directory in a browser to make sure the upload worked and so I can copy the URL.
- Paste the URL to whoever I want to share it with.
This is slow and boring. The other day my fellow intern Larry showed me his way of auto-uploading these screenshots, so I shamelessly stole it, modified it a little and am now claiming it as my own:
First, I made an Automator application that runs the following shell script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | USER="user" HOST="host.com" UPLOAD_DIR="/var/www/screenshots" WEB_DIR="screenshots" LOCAL_DIR="$HOME/Desktop" FILE="Screenshot.`date +%m%d%H%M%S`.png" URL="http://$HOST/$WEB_DIR/$FILE" screencapture -xi $LOCAL_DIR/$FILE ping -t 1 -c 1 $HOST if [ $? -eq 0 ]; then scp $LOCAL_DIR/$FILE $USER@$HOST:$UPLOAD_DIR/ rm $LOCAL_DIR/$FILE echo $URL | pbcopy growlnotify -m "Screenshot uploaded to $URL" else echo $LOCAL_DIR/$FILE | pbcopy growlnotify -m "Screenshot copied to Desktop" fi |
Then, I used Quicksilver to bind Cmd+Shift+4 to call this Application. I have an SSH key set up so the SCP works without any interaction from me. The script takes the screenshot, checks to see if the server is up, uploads the image, and copies the URL to my clipboard. If the server is down, it reverts to the default functionality of leaving the image on the Desktop.
The workflow is now:
- Take a screenshot of a selected area with Cmd+Shift+4.
- Magic!
- Paste the URL to whoever I want to share it with.
Larry just has Quicksilver run the code as a shell script but I like the automator application since it adds a little busy spinner in the taskbar while the script runs since uploading can be a bit slow if the connection sucks.
Dependencies: Quicksilver, Automator, growlnotify, I suppose. Automator, growlnotify, and possibly Quicksilver are all optional.