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.
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:
Open Automator.app.
From the menu item “File” > “New” choose “Services”
Now there are 3 steps to be filled out like so:
First, edit the top so that “Service recieves selected: files or folders in Finder.app“.
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”
December 8th, 2009 at 18:58 (GMT-1)
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.)
December 11th, 2009 at 01:38 (GMT-1)
Nice tip, but somehow the folder or file I selected in Finder appears twice in the Textmate drawer. Do you have the same problem?
December 16th, 2009 at 21:38 (GMT-1)
@Daniel. Actually yes I have the same problem. Please let me know if you come up with a fix !
December 6th, 2010 at 03:54 (GMT-1)
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:
FROM:
cat | xargs mate
TO:
mate $1
January 3rd, 2011 at 11:10 (GMT-1)
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!
January 8th, 2011 at 12:25 (GMT-1)
[…] http://justaddwater.dk/2009/12/08/how-to-add-open-folder-in-textmate-to-finder-context-menu/ Share this article […]
July 25th, 2011 at 16:23 (GMT-1)
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”