Markdown References with Keyboard Maestro

September 11, 2011 by Gabe | [mmd] |

I have been recently shifting a large chunk of my TextExpander snippets to Keyboard Maestro. I still plan to use TextExpander for basic snippet expansion but I find the depth of Keyboard Maestro allows me to build custom tailored tools that fit their intended uses much better.

For example, here a juiced up version of a snippet for inserting Markdown references from Safari. First, here's what my TextExpander snippet did:

1. Copy URL from Safari

2. Switch to NVAlt

3. Bracket the link phrase

4. Type "mdr" to trigger the snippet

5. TextExpander inserts a double bracket then simulates the CMD-Down Arrow (bottom of document) and a return key. TextExpander then inserts "[%I]: %clipboard"

That's pretty nice. It's much better than manually creating link references. There's still some tedium though. I have to copy the link in Safari. I have to add the link reference text and I don't have a title for the link. Basically, there's still some repetitive typing that doesn't need to exist. I know I could fix a lot of this in TextExpander now that it supports AppleScript and Shell Scripts, but there are still some rough edges. Trust me, I've tried.

The Keyboard Maestro Version

The Keyboard Maestro version simplifies the entire process. I browse in Safari to the page I want to reference. I jump back to whatever application I am working in (usually NVAlt). After I bracket the link phrase, I simply type "mdr" and Keyboard Maestro presents a pop-up window asking for the link tag.

Keyboard Maestro Dialog

The link tag is inserted with brackets and a reference is immediately added at the bottom of the document for whatever page is currently at front in Safari. It even grabs the page title for the link reference.

The result of the macro

Believe it or not, this is a pretty simple macro. There's a bit of AppleScript to get the URL and title (both scripts could be combined but I reuse these a lot in other macros) but overall, it's basic Keyboard Maestro functionality. I have built a small arsenal of these little macros. While I would be completely lost working on someone else's Mac, I take comfort in the ease at which I can work now.

Keyboard Maestro Macro

Click Here for Larger Version

You can download the macro file here.


I will be posting more of my macros as I clean up TextExpander and get my Keyboard Maestro macros in order.

blog comments powered by Disqus