Send to New BBEdit Page

Looking for an action that will send the contents of the Drafts page to a new BBEdit page. I tried to edit the Ulysses action, but I am unfamiliar with the procedure for identifying the “destination” (I know you don’t need to use the x-callback designation any longer). Help is appreciated.

1 Like

I don’t believe BBEdit has any URL scheme support. Until Drafts gets some additional Mac-specific features (like AppleScript integration) I do not believe this is possible directly with Drafts actions - could be done via Keyboard Maestro or other tools.

1 Like

BBEdit does not have any URL scheme support. It has extensive AppleScript support and there’s even a bbedit tool for the command line.

I do have a Keyboard Maestro macro which will allow me to open the current text that I am editing (from any window in any app) into a BBEdit document, and then when I close the BBEdit document, the text is placed back in the originating app. (This was originally meant to replicate the functionality of the now-defunct “QuickCursor” app.)

It’s not Drafts-specific in any way, but if you’re interested in it, let me know. I think it may even already be on GitHub somewhere.


BBEdit does have a URL scheme to open a file. Theoretically, you should be able to save a file to Dropbox or iCloud Drive and then this should work:


But I just couldn’t get it to work.

First problem is getting the path of the saved document. I couldn’t figure out how to get the full path from a draft saved via the cloud FileManager object. Something like this:

(() => {
    'use strict'
        fileName = 'testbbedit.txt',
        baseURL = 'x-bbedit://open?url=file://',
        cloudFM = FileManager.createCloud()
    cloudFM.writeString('/testbbedit.txt', 'open this file in BBEdit')
    // how to get the full path to the saved document?

It falls apart, however, because I couldn’t figure out how to get the saved document’s full path. Despite the documentation saying “Array of full path will be returned” from listContents, it’s actually an array of paths relative to the iCloud Drive app container directory.

But even if, for the sake of testing, I paste a full document path in to my script, app.openURL() fails to open the x-bbedit URL. I think maybe it has to do with iCloud Drive URLs having tildes in the iCloud~com~agiletortoise~Drafts5 part? Do they get encoded to %7E instead? A URL to a file on my desktop (i.e., without any tildes) opens just fine from a Drafts action.

Manually pasting in a URL to a file in my local Dropbox directory also worked, so perhaps a file could be saved using that method, but again I think that stumbling block would be getting the full path to the file.

Sorry if this post rambles a bit. TLDR: It should theoretically be possible to save a draft to a document (e.g., in iCloud or Dropbox) and then open it in BBEdit using the x-bbedit URL scheme, but I can’t make it work.

1 Like

I would like to see the macro if it’s not too much trouble to find it.

For now, I am doing it manually-Copy the text I want; go to BBEdit; Paste in a new document. Not the most labor-intensive process :wink: but I should be able to create a KM macro to do it with one keystroke without too much trouble.

I just played with this a little. FileManager does not expose a full path. That would not have been very meaningful on iOS, but would be a good addition for Mac - will make a note.

I made an example BBEdit action that saves to iCloud Drive, then opens that file in BBEdit via URL scheme. The script is as follows…and will need to have at least the user name edited to work on your system.

// edit these for your file and mac user account name
let fName = "BBEdit.txt";
let macUser = "greg";

let iCloudPath = `/Users/${macUser}/Library/Mobile Documents/iCloud~com~agiletortoise~Drafts5/Documents/${fName}`;
let fm = FileManager.createCloud();

fm.writeString(`/${fName}`, draft.content);

Here it is:

if you need any help, send me a PM.


Will do. Thanks very much.

FYI, a little followup on this thread:

  1. With the new AppleScript support, it’s easier to work with BBEdit. See Send to BBEdit example.
  2. The FileManager object now has ways to access it’s basePath and baseURL. Docs.