I love the Drafts app for the iPhone, and I love automating stuff. The downside to using Drafts is that the workflows I’ve set up aren’t possible with any software on the Mac. I cobbled together some methods to achieve at least the one most common task I have, appending info to a master plain-text log file on Dropbox. Here’s how I did it.
[UPDATE 2017-12-30: here’s the companion article on prepending text files]
The first method uses TextExpander to append my Journal.txt file with the clipboard contents, while also prepending it with a date/time stamp.
Create a new TextExpander snippet with “shell script” as the format in the drop down menu, and assign a shortcut (I chose j// for mine):
DATE_PREPEND=$(date +"%Y-%m-%d %r")
echo -e "\n## $DATE_PREPEND: $FILE_CONTENT" >> /Users/George/Dropbox/Notes/Journal.txt
If your clipboard was the text “Clipboard contents”, you’d see
## 2013-03-21 1:01 AM: Clipboard contents
added to the end of your Journal.txt file. All I need to do is copy some text, invoke the snippet shortcut, and the text on the clipboard gets magically added to my Journal.txt file.
The parts that I struggled with were the new lines (
\n). I had to add the
-e to get them to register. I have no idea why, just found it out online as one option. The rest of the code was graciously provided by a fellow Hazel user over on the Noodlesoft forums. The “
pbpaste” command grabs the content of the OS X clipboard. The
## is just a visual separator, and the date format can be tweaked to your preference.
Of course, you need to do this for new text as well so in this case I created an Automator Service that does the same, but prompts you for text. Use the same shell script, but omit the first line (
Obviously you’ll need to change the path to the .txt file you’re using.
There’s probably a better shell script that will grab the clipboard contents instead of doing it through Automator, but I’m lucky I made it this far.
Next, you can assign a keyboard shortcut to this service for system-wide access.
If you have more than one log file you’d like to append, I guess you’d just create a new version of each of these and change the file path. And if you were a real coder (unlike me), you might be able to get a shell script going that would also do some Evernote stuff, tweet, or even add new Reminders and such.
For me, I mostly needed this to log random info while at the Mac instead of doing this via the iPhone. I’ll probably set up another one to use with my plain-text task list as well.
I have a bookmarklet set up on the iPhone to pull the title and URL from a webpage and send it to Drafts, for appending to the Journal.txt file, and this bookmarklet will help do something similar on the Mac so you can use it with these hacks.
For those curious, I’ve been working with a plain-text log file setup using Drafts, Dropbox, Hazel, Day One, and the actions over at IFTTT with RSS feeds, Foursquare checkins, and more. Very similar to this article over at Cult of Mac, which I discovered after setting up my system.
I’ll post soon on my setup to save a single journal entry text file to Dropbox via Drafts or Notational Velocity/nvALT, and have the contents automatically added to Day One on the Mac, then prepend the entry with a date/time stamp and append to the plain-text log file.
Why did I spend all my time with these redundant setups? I like Day One, but I also like the idea of not being locked into one system. My plain-text log file setup is in a way similar to the Momento app (which does export the data as plain text), but with my plain-text setup there’s almost zero friction. With Day One and Momento, while I like the apps, I prefer to use them for viewing content — not spending time adding it.
With this setup for the Mac and my Drafts setup, I can quickly grab info or jot it down, fire it off once and have it added to all the places I’d like to store it, in the format I prefer.