For many years I have been an advocate for automation for repetitive routines when using my computer(s). I have dabbled in AppleScript and heavily in Excel, but I think a highly overlooked application for Mac OS X is Automator.
What is great about Automator is that it enables you a large number of Plug-Ins right off the bat that are all somewhat useful. I originally learned about Automator when I had gotten fed up with building a download file filter using AppleScript. I just wasn’t prepared for learning the AS language at the time, and in a sense, I’m glad I gave up on it and explored Automator.app which was fairly new at that time.
Automator was first introduced way back with Mac OS 10.4 (Tiger) and over the years I’ve never really seen people talk about, much rather use, this program much. Since Automator’s introduction back in 2005 there have been many additions to the program with each new OS X release, sadly I have not delved nearly deep enough to stay up to speed. But for what I do know, I have always quietly enjoyed using the little ‘Pipe holding robot’ for solutions like what I am about to explain.
When I am working on a development project I, like many others, load the entire folder into Sublime Text 2. Now you can use the Sublime command line interface to do this by running the
subl . command from the Terminal when you’re in your working directory. This works just fine and I am all about it. But as I started into more front end work I realized I didn’t always have a Terminal window open. Why open a Terminal window to run the subl command? There’s gotta be an easier way right? (Although I can highly recommend Go2Shell.app to quickly go from a Finder window to that directory in the Terminal.)
The solution to this was a dead simple Automator workflow. So simple that I thought it was a great introduction topic to talk about. What I came up with is a Finder contextual menu item (i.e. right-click menu) that loads whatever folder you select into Sublime.
When you first open Automator you are given several choices for the type of document you want to create. I haven’t explored all of these items too much, but in our case we will use a Service.
Amongst many things, a Service is what can provide the Finder a contextual menu item that performs some operation. After you choose this item you get the blank document to drag and drop your workflow actions. For this we really only need one Action – “Open Finder Items”. It helps to use the little search bar to quickly find this Action.
Ok, so you’ve dragged your “Open Finder Items” action into your work area on the right and selected Sublime Text 2 from the “Open with:” dropdown menu. You should have something that looks like this.
You’ll possibly see one other thing I’ve changed, which is above the workflow area. The “Service receives selected” dropdown should be set to “folders” so that this workflow will expect a folder object (although if you put folders or files it’d be ok too).
And that’s it! You’re done with the workflow, so let’s save it as “Open in Sublime Text” and go try it out!
Head into the Finder and select a project folder you want to open into Sublime, right-click and select the Services sub-menu at the bottom. Select your new “Open in Sublime” contextual item and your project should now be opened up and you’re ready to get to work!
One last thing, in case you want to know where this file is stored locally, it is found in: ~/Library/Services