Home | Blog | RSS

Quick Open Action for Drafts

2019-05-21

Just whipped up a super simple little Drafts script action which I thought I’d share. By default, Drafts opens with a blank new draft, ready to capture your thoughts. If you’ve just been working on a draft, however, it will reopen when you switch back to the app, as long as you haven’t been inactive for too long. In settings, you can adjust that time delay to whatever suits you best. When you find your own sweet spot1, it’s a fantastic feature which pretty much always does what you want without your having to think about it.

Just occasionally though, you end up on the wrong end of that delay. If you launch expecting a blank draft, and your previous one is still there, you just hit ⌘N. But what happens if you end up with a blank draft when you were expecting to reopen your previous one?2 My solution was to create a two-line script action to quickly open the most recently accessed draft3 with the keyboard shortcut ⌘O:

let recent = Draft.query('', 'all', [], [], 'accessed', true, false)[0]
editor.load(recent)

It’s one of the simplest script actions I’ve made, but also one that I now use frequently. You can download it now from the Action Directory.

  1. Five minutes for me. 

  2. Drafts does offer a “focus mode” to prevent this from happening, so this action is just for when I forget to turn it on. 

  3. The action only works if you don’t edit the blank draft first. For a longer list of recent drafts, there’s a combination of built in keyboard shortcuts you can use. Just hit ⌘\ then use the right arrow key to select Recent Drafts, up and down arrow keys to navigate between them, and return to open the one you want.