Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
OSX Bash script to snap an interactive screenshot into your Dropbox public folder and copy the public url to your clipboard.
#!/bin/bash
DATE=$(date +"%Y-%m-%d");
TIME=$(date +"%I.%M.%S");
AMPM=$(date +"%p");
FILENAME=Screen\ shot\ $DATE\ at\ $TIME\ $AMPM.png;
# You can export you DROPBOX_USER_ID in your .profile
# or hardcode it here by replacing YOURDROPBOXUSERID
DB_USER_ID=${DROPBOX_USER_ID-YOURDROPBOXUSERID};
# Make sure you create the Screenshots directory in
# your public directory
DB_BASE_DIR=~/Dropbox/Public/Screenshots;
DB_BASE_URL=https://dl.dropboxusercontent.com/u;
screencapture -i "$DB_BASE_DIR/$FILENAME";
# user may have escaped out of the screencapture
if [ -f "$DB_BASE_DIR/$FILENAME" ];
then
URL_FILENAME=$(python -c "import urllib; print urllib.quote('''$FILENAME''')");
URL_LONG="$DB_BASE_URL/$DB_USER_ID/Screenshots/$URL_FILENAME";
# copy long url, if you paste before the shortener returns
echo $URL_LONG | pbcopy;
fi
Owner

jasonbouffard commented Jun 28, 2011

Pretty easy to add a global keyboard shortcut.

  1. Open Automator
  2. Select Service
  3. Add shell script
  4. Put in the path to this script
  5. Save as something useful "Screen Shot to Dropbox"
  6. System Preferences -> Keyboard
  7. Keyboard Shortcuts
  8. Services
  9. Find "Screen shot to Dropbox"
  10. Click to the right of the name
  11. Add a shortcut. I used Shift+Command+5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment