Day One Automation

Posted by on Thursday 23rd of April 8:05 AM
{% img center /images/2015-04-23-day-one-automation.jpg 460 250 'Day One Automation' %}

Day One (iOS, Mac) is a nice journaling app that I like to use to collect quotes, as well as my life log. Recently I've been trying to "optimize" a couple of things, which means I've been removing and automating stuff.

The two command line utilities that are really helpful are jrnl and dayone_export.

jrnl

jrnl is in and off itself a diary software. It is nice enough to read and write Day One diaries. This means you can use the app to add new Day One entries using a scripting solution, like Keyboard Maestro, on your Mac without the Mac app itself. This means you can automate it. The app also allows you to export entries in JSON.

It allows you to use an external editor, such as Vim. It has advanced filtering. And so much more. The command line utility is a full diary app, with support for multiple diaries. So if quotes overfill your Day One diary, you can move all of them to a new diary relatively easy. (Read FAQ and Advanced Usage)

dayone_export

dayone_export is a great way to export, as the name implies, Day One entries to something else. This utility is great to make a book out of a journal. To customize the output you can setup export templates in the Jinja format. I'll stick with the quote workflow, because that's what I actually use it for.

In my case I want to display a random quote on my desktop with Geek Tool, or a similar app. The following command does exactly that, and it removes empty lines from the export:

dayone_export --format txt --tags quote --template quotes.txt ~/Dropbox/Apps/Day\ One/Journal.dayone | sed '/^$/d' > ~/.geektool/quotes.txt

Just in case you're curious this script displays a random quote from the file (I'm also using this in a TextExpander snippet named aff -- short for affirmation):

f=~/.geektool/quotes.txt; n=$(expr $RANDOM \* `cat $f | wc -l` \/ 32768 + 1); head -n $n $f | tail -1

This is the quotes.txt template:

{% raw %}
{% for entry in journal %}
{{ entry['Text'] }}
{% endfor %}
{% endraw %}

No dates or anything, just the entry text. Most quotes are just one line too.