Apple How To

Instantly share screenshots on your Mac for free (how-to)

As reported on The Verge.

by Zenonas Kyprianou

Dropbox macbook air

Have you ever wanted a speedy way to share screenshots, that is free, and doesn’t require you to give away your privacy? I have been on the market for a product that fits these criteria. I’ve gone through multiple sharing apps, such as GrabBox, puush, or Slingshot — some worked fine, some didn’t, others wanted me to pay, or register to a service. I never really managed to find one that is simple and discreet to my liking, so I decided to combine two of the tools that make my life a million times easier on my Mac. Dropbox and Automator. The idea is to have the default OS X screenshot key combinations (⌘-⇧-3 and ⌘-⇧-4) save screenshots directly in Dropbox’s public folder. This could be accomplished by simply changing the default path for screenshots, but this is not enough, I want to go a step further.

Folder-actionI want to have the link to the screenshot copied to my clipboard as soon as the image is uploaded, ready for sharing. This is where Automator comes in.

1) The first step is to launch Automator, which is found in the Applications folder.

2) You are going to create a new “Folder Action,” which allows you to specify events that happen as soon as a change in a specified folder is detected. The folder we are looking to track is the Desktop, as this is where OS X screenshots are saved by default.

Folder-action-folder

3) Next, you need to filter the contents of the desktop so that only the screenshot is selected. To accomplish this you need to drag from the actions palette, on the left, the “Filter Finder Items” action, and configure it as follows.

Folder-filter

4) Now that the script has the screenshot selected, it needs to move it to Dropbox’s Public folder. The action needed here is “Move Finder Items.” This can be dragged from the palette on the left as well.

Folder-movefinderitem

5) This is where things get interesting, you need to provide a short shell script that will be executed every time we take a screenshot. This script will essentially construct the URL that links to our screenshot and copy it to the clipboard. To add the shell script drag in from the palette the “Run Shell Script” action. You also need to pass the input to the script “as arguments.” Clear the default snippet and paste in the following code. You also need to replace the “XXXXXXX” part in the first line of the code with your Dropbox user id. This can be found by using Dropbox’s “Copy Public Link” feature on any existing file in the public folder. Pasting this link anywhere will reveal the user id which you need to include in the script.

combined="https://dl.dropbox.com/u/XXXXXXX/"$(basename $1)
final=`echo $combined | sed 's/ /%20/g'`
echo -ne ${final} | pbcopy
afplay /System/Library/Sounds/Hero.aiff

Folder-runshellscript

6) The only thing remaining is to add a Growl notification, so that you get a message when the process is complete. To include this you need to make sure you have Growl installed, and drag in from the palette the “Show Growl Notification” action.

Folder-showgrowl

7) Finally save the folder action and exit Automator. That’s it, you should now be able to instantly share any screenshot, simply using your default OS X key binding, wait for the notification and paste the link wherever you want.