How To add “Open folder in Textmate” to Finder Context Menu

I wanted to add a menu item in Finder’s context menu that would open the selected folder in Textmate.
Textmate context menu item: Open selected folder in  Textmate

A google search suggested the method described by K. Adam Christensen on his blog: “Opening a directory in TextMate from Finder“. However, from the documentation, I learned that that method is now outdated. Snow Leopard users should use “Services” and not “workflow” for setting this up.

Here is what I did:


From the menu item “File” > “New” choose “Services”


Now there are 3 steps to be filled out like so:

Automator final setup for "open in textmate" context menu itm
First, edit the top so that “Service recieves selected: files or folders in“.

Second, add the action “Get Selected Finder Items” from the left column (use the search field to find, then drag selected into the right work area).

Third, add the action “Run Shell Script” to your service. Fill in the following command:

cat | xargs mate

Finally, choose “File” > “Save…” and give it a name like “Open in Textmate”

7 Responses to “How To add “Open folder in Textmate” to Finder Context Menu”

  1. Joe Alba Says:

    Great tip! I’ve been looking for this feature for a while now.

    But for some reason, it isn’t working for me. I followed the steps, but this service does not appear when I right-click a folder.

    I checked my ~/Library/Services folder, and the service I created was saved as ‘Open in TextMate.workflow’

    Got any tips that could help me out? Does your service wind up with the .workflow extension also?

    (I’m running Snow Leopard — upgraded from Leopard, not a fresh install.)

  2. Daniel Says:

    Nice tip, but somehow the folder or file I selected in Finder appears twice in the Textmate drawer. Do you have the same problem?

  3. Jesper Rønn-Jensen Says:

    @Daniel. Actually yes I have the same problem. Please let me know if you come up with a fix !

  4. Adam Says:

    To fix the “double” loading issue:

    In the “Run Shell Script” Automator action, in the “Pass Input” drop down, change from “to stdin” to “as arguments”

    Change the script:

    cat | xargs mate

    mate $1

  5. Scott Says:

    Thanks Adam, that solved the double-loading issue for me as well.

    Also, for whatever reason, the workflow wasn’t picking up my $PATH variable, so I actually had to enter:

    /usr/local/bin/mate $1

    as the shell script. Other than that, though, works like a charm!

  6. Open folder in Textmate | Elink Media Says:

    […] Share this article […]

  7. Henrique Says:

    Great tip!

    Using what Adam and Scott sad, but with the argument surrounded by double quotes avoiding problems with path that contain spaces.

    /usr/local/bin/mate “$1”