OpenInTextMate finder plugin with TextMate2 in MacOSX 10.7

After upgraded MacOSX to 10.7 and TextMate2, I find that the former OpenInTextMate plugin of Finder doesn’t work at all. Life went so hard without this small tool that I tried again and again to find out how to make it work. And finally, I did, and it’s very very simple!

Download OpenInTextMate here! Installation is very simple, just drag the application and drop on to the toolbar of Finder.

 

The OpenInTextMate plugin was written with AppleScript. Here are the steps that I create this application:

First, open application “AppleScript Editor” under your “Applications”=>”Utilities” folder, past the following code into the editor

-- Opens the currently selected Finder files, or else the current Finder window, in TextMate. Also handles dropped files and folders.

-- By Henrik Nyh
-- Based loosely on http://snippets.dzone.com/posts/show/1037

-- script was clicked
on run
	tell application "Finder"
		if selection is {} then
			set finderSelection to folder of the front window as string
		else
			set finderSelection to selection as alias list
		end if
	end tell

	tm(finderSelection)
end run

-- script was drag-and-dropped onto
on open (theList)
	tm(theList)
end open

-- open in TextMate
on tm(listOfAliases)
	tell application "TextMate"
		open listOfAliases
		activate
	end tell
end tm

Then press ⌘+S and save this script as application with name OpenInTextMate. Now you will get an application that will open and activate application TextMate with double click. Right click it, and choose “Show Package Contents” in the context menu. Replace the file “Content=>Recources=>droplet.icns” with the former one. It’s the icon of this new created application.

OpenInTextMate

Finally, drag this application and drop on to the toolbar of Finder.

This entry was posted in 杂七杂八 and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Verify Code   If you cannot see the CheckCode image,please refresh the page again!