Drafts 19 (macOS) Released - Quick Search, AppleScript

Drafts 19 (macOS) has been released in the Mac App Store, details below.

See also: iOS Release Notes


What’s New

  • Quick Search: Global quick search feature to query for drafts, actions, workspaces and common commands in one place.
    • Accessed via search button in the toolbar, the Edit > Find > Quick Search menu command, or with the shift-command-F keyboard shortcut.
    • /quickSearch?query= URL action to open directly to quick search. Details
    • app.showQuickSearch(initialQuery) scripting function. Docs
    • Related change: Searches (in quick search and in draft list) now support tag matches in additional to full text searching, in addition to their support for "exact phrase" with quotes and -omission with hyphen
    • Quick Search feature requires macOS 10.15.1 (Catalina) or greater.
    • Documentation
  • AppleScript
    • “Run AppleScript” action step can be used to execute AppleScripts passing information about the current draft.
    • AppleScript script object for calling AppleScripts from JavaScript, with more advanced control of parameters, subroutines called, and easier access to return values.
    • Basic incoming AppleScript support for creating new drafts. Additional support for AppleScript coming in future updates. Example: tell application "Drafts" make new draft with properties {content: "my draft", tags: {"blue", "green"}} end tell
    • AppleScript examples action group
    • More info and examples
  • ShellScript script object for running Unix shell scripts from Drafts script action steps, with the ability to pass command line arguments, and access standard output and errors.
  • Marked app streaming preview support. If enabled in Preferences > General, the editor will live update the stream Marked watches in it’s “Streaming Preview” window. Requires Marked app be installed. Details
  • FileManager script object additions:
    • baseURL and basePath properties return full file:/// URL or POSIX path to the base directory used by the FileManager instance. This can be useful in cases where the full location of files is needed.
    • writeJSON(path, obj) and readJSON(path) convenience functions for saving and restoring JavaScript objects in files.
    • FileManager docs
  • app.showDraftInfo(draft?) function to display details of a draft. Docs
  • Additional Workspace script object properties:
    • loadActionListGroup (ActionGroup)
    • loadActionBarGroup (ActionGroup)
    • loadFolder (“inbox”, “archive”, “trash”, “flagged”)
    • Docs

Other Changes

  • Fix: Better live updating of changes if the same draft is open in multiple windows.
  • Fix: Changing only some advanced settings in the action editor, and nothing else, could result in the change not being saved.
  • Fix: “-” button for deleting actions in action manager did not work properly with multiple selections.
  • Change: Searches now also search tag names in addition to searching full text.
  • Fix: “Manage Actions” window did not behave properly in full screen mode.
  • Fix: Several crashes related to open and closing additional drafts windows when the app first launched.
  • Change: Improve identification of HTML tags in Markdown syntax.
  • Misc. other reliability and performance improvements.

For a complete history of updates, visit the changelog


Quick Search sounds great! Unfortunately, because I’m using some older software, I’m not able to update from Mojave to take advantage of it. But I’m glad I can use it on iOS.

I see the Ruby example in the docs uses a #!/usr/bin/env ruby shebang line. Is the environment in which the script runs the same barebones environment one would have if there’s no .bashrc or .bash_profile to change the $PATH? Or are you somehow processing the user’s initialization files before running the script?

I’m not altering anything, so it’s possible that shebang would need to be adjusted for the way you have Ruby installed.

To be honest, I did not get to test that feature as extensively as I’d like to understand the mechanics of the Unix environment used. The script gets saved to the ~/Library/Application Scripts/com.agiletortoise.Drafts-OSX folder, and handed off and executed using NSUnixUserTask, which runs it in the user space.

Thanks, I’ll do some testing of the environment when I’m at my Mac tonight.

Read the examples section of man env and you’ll see why it’s typical to use #!/usr/bin/env ruby.

Essentially the main reason is that the ruby executable might possibly be a script that itself needs to be executed. For example, rbenv uses a shell script to call through to the actual ruby binary.

It should be safe for pretty much any use case, but I’d be interested to hear if you learn about something I haven’t considered yet.

See this