Sublime Text Macro to Open a Folder

July 22, 2012 by Gabe | [mmd] |

This macro requires the Sublime Text CLI to be configured. I followed the instructions here with a minor modification. Keyboard Maestro does not recognize the command in usr/local/bin so I created it in /usr/bin:

sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/bin/sublime

This provides access to Sublime Text from the terminal on a Mac. My command is

sublime some instructions use the default name subl.

This macro launches Sublime Text with my NVAlt folder as the source:

This macro opens the current Finder folder view in Sublime Text as a source:

Here is the AppleScript portion:

tell application "Finder"

    try

        activate

        set myWindow to folder of front window as string

        set myPath to (get POSIX path of myWindow)

        return myPath

    end try

end tell

Why do it this way? Well, I don't want to create project files all over my file system. I just want to get a file list in Sublime Text and then use the "Find in Files" functionality (shift-⌘-F).

Older articles

  1. Dictionary Macro

    July 13, 2012 by Gabe | [mmd] |

    As pointed out in the comments to this post about using Sublime Text to write, it's annoying that it will not use the OS X spell checker and dictionary built into other text editors.

    For example, here's the dictionary lookup in NVAlt:

    Sublime Text 2? Not so much ...

  2. User Agent Macro

    June 07, 2012 by Gabe | [mmd] |

    I regularly switch my Safari user agent to "iPad" so I can play embedded YouTube videos without errors. It seems that many embedded videos still require flash if they see I am using Safari. Switching to the iPad user agent causes the videos to be played as HTML5 without need ...

  3. Convert Multiple URL's to MD Image Links

    May 31, 2012 by Gabe | [mmd] |

    A short macro I use to convert URL's into Markdown image links. This macro leverages Keyboard Maestro's Regular Expression matching in the Search and Replace action.

    I've blatantly stolen John Gruber's regular expression for matching URL's which is the best I've tried.

    A tiny ...

  4. Image Resize Macro [Link]

    May 29, 2012 by Gabe | [mmd] |

    An alternative macro to resize images over at TheGeeksCompanion.

    I still prefer the flexibility of my macro but for many people, simpler is better.

  5. Keyboard Maestro Resize Image Macro

    May 24, 2012 by Gabe | [mmd] |

    Here's a macro to take advantage of the new Keyboard Maestro 5.3 Image actions. This macro processes an image (or several) selected in the Finder. If the image is larger than 600px wide, a new scaled copy is created that is 600px wide. But the trick is to ...

  6. Keyboard Maestro Zip and Share [Link]

    May 24, 2012 by Gabe | [mmd] |

    I'm just catching up on my Keyboard Maestro reading. There's some good stuff happening with it these days.

    Eugene Gordin has been evolving some really nice macros to fit some unique use cases. This one zips a group of files and shares them on Dropbox for a limited ...

  7. DuckDuckGo Bang Macro

    May 22, 2012 by Gabe | [mmd] |

    Prompted by the recently released Bang On iOS app1, I decided to make a macro for Keyboard Maestro that could accomplish the same thing with Safari.

    This macro is really just a series of scripts, so it could easily be converted to a LaunchBar plugin. The macro grabs the ...

  8. Keyboard Maestro 5.3 Update

    May 22, 2012 by Gabe | [mmd] |

    Another solid update. This time Peter has added a bunch of image manipulation actions and better mouse controls. Every time I build some elaborate solution with twine and tape, Peter comes along and embarrasses me with a new feature set in Keyboard Maestro.

  9. ImageOptim Macro

    May 02, 2012 by Gabe | [mmd] |

    From a recent Gruber link, ImageOptim optimizes images without dramatically changing the image quality. I did some testing and I can not see a difference in quality but the file sizes are typically 30-50% smaller.

    I often feel guilty about the large images in some of my posts. I do ...