Scripts for using Drafts with an external text editor.
Drafts stores its notes (drafts) in a database, so they can't be opened in an external editor directly. These scripts offer two possible workarounds.
Components:
This action writes the current draft to file, opens the file in a specified editor, waits for the editor to quit, and reads back the edited file. This action is blocking in the sense that no other Draft actions can be invoked while the external editor is open, so is best for quick edits.
Components:
This second option is more involved and uses several actions as well as a macOS "shortcut". It works like this:
- Invoke the Make Proxy File action. This writes a copy ("proxy file") of the current draft to a user-specified directory and copies its path to the system clipboard.
- Edit the proxy file using your editor of choice.
- Invoke the shortcut drafts-proxy, e.g. using the terminal:
shortcuts run drafts-proxy
. This goes through all proxy files and writes them back to their corresponding drafts. - Finally, when you are done, invoke the Delete Proxy File action.
To simplify this workflow there is also an action Make Proxy File and Edit in External Editor whose purpose should be clear from the name.
You probably want to set up your editor so that step 3 is handled automatically. For example with Vim you could add the following autocommand:
autocmd! BufWritePost <your proxy file directory>/* silent !shortcuts run drafts-proxy &