Send Drafts (iOS) Content to Quicksilver or Clipboard on OSX

Tags: , , , , , , ,

Bottom Line: This is another way to send text from Drafts on iOS to either Quicksilver or your Mac’s clipboard.

There are numerous apps whose primary purpose is to share text (or links, images, etc.) between your iOS device and your computer. This is something I thought of today when I was messing around with Drafts and realized it would be easy to script. It works pretty well, but doesn’t work for images or files, just text based stuff and links. The way I have it set up also depends on Hazel, another one of my favorite Mac apps, but I’m sure it could also be set up as a folder action / AppleScript.

Drafts Setup

The first step is to make a new “Dropbox Action” in Drafts. The action should create a new text file in a specific folder in Dropbox. Name the file something unique like “sendDraftsToClipboard”, leave the extension as txt, and make sure to select the “predefined” option for the name. Leave the contents as [[draft]], which should be the default value.

Hazel Setup

Next, set up your Hazel rule to monitor that folder for “full name” :: “is” :: “sendDraftsToClipboard.txt” (or whatever you’ve chosen). Set the resulting action to “run shell script,” do a little time traveling, and choose the external shell script you’ve saved from below.

Shell Script Setup

Here is the script. There are a few places where you can comment or uncomment to customized it a bit. It’s currently set to delete the text file automatically to ensure that there aren’t problems with file renaming or anything.

Because sending to the clipboard is otherwise silent, it’s nice to have some kind of success / failure notification. If you have Growl and growlnotify installed, adding the following to the end of line 6 (cat and pbcopy stuff) will give you a growl notification for either success or failure.

If you haven’t noticed, I’m a big fan of Quicksilver, so I wrote this to be easily modified to send to Quicksilver instead of the clipboard. A second benefit here is that Quicksilver pops up whenever it has successfully received the text, so I know it got through and don’t need the growlnotify stuff.

In order to get this working with Quicksilver, you’ll need to have the Command Line Tool plugin installed. It’s best to find it in the Quicksilver preference pane and install from there, but you can also get it from the official Quicksilver plugin repository. Unlike other QS plugins, there’s an extra step: go to the “preferences” tab and click “install” — you’ll need to authenticate as an admin. (Thanks to this thread for that tip.)

Extra Step to Install Command Line Tool

I recommend not to set Drafts to delete the draft when it’s sent, since any problems could then lead to you losing whatever data you were trying to send, which can be a pain. Sometimes Dropbox is a little slow, for example. As I’ve mentioned before, you can always just send yourself a text with Messages.