Is there a way to use a Finder hot key to open a folder in TextMate?

Solution 1:

I think that's a bug with Finder. Services that receive folders as input don't seem to be listed in the Services menu when folders are selected (but it only applies to column view; they are listed in other view modes).

In any case, one alternative would be to just use an AppleScript without wrapping it as a service. You can give it an app-specific shortcut with FastScripts.

try
    tell application "Finder"
        open (get selection) using path to application "TextMate"
    end tell
end try

Solution 2:

After seeing @Lri's answer I discovered that my original service would work in the Finder as long as I wasn't in column view. Since that's the view that I use most of the time, I decided to see if I could get @Lir's basic solution working without the need for an external application. Here's what I did:

  1. Open Automator and choose "Service" from the options of what to make.

  2. Set "Service receives" to "no input" and "in" to "Finder.app".

  3. Drop a "Run AppleScript" action onto the main window.

  4. Drop the code @Lri provided into place so you end up with:

    on run {input, parameters}
    
        try
            tell application "Finder"
            open (get selection) using path to application "TextMate"
            end tell
        end try
    
        return input
    end run
    

    enter image description here

  5. Save the action as "Open via TextMate".

  6. Under "System Preferences" -> "Keyboard" -> "Keyboard Shortcuts" -> "Services" -> "General" add my preferred shortcut to the "Open vie TextMate" item.

    enter image description here

This works in all my Finder views (including column view) for Mac OS X 10.7.3 and TextMate 1.5.10.