-- Opens the current finder window folder in TextMate. Or open a file or folder in TextMate by dragging it onto this script. -- adopted from a script I found in the comments of this article: http://www.macosxhints.com/article.php?story=20050924210643297 -- Instructions for use: -- paste this script into Script Editor and save as an application to ~/Library/Scripts/Applications/Finder/open in TextMate -- run via the AppleScript Menu item (http://www.apple.com/applescript/scriptmenu/) -- Or better yet, Control-click and drag it to the top of a finder window so it appears in every finder window. -- Activate it by clicking on it or dragging a file or folder onto it. -- Another nice touch is to give the saved script the same icon as TextMate. -- To do this, in the finder, Get info (Command-I) of both TextMate and this saved script. -- Click the TextMate icon (it will highlight blue) and copy it by pressing Comand-C. -- Click on this script's icon and paste by pressing Command-V. -- Another way to give it the same icon as TextMate is to save the script as an application bundle (instead of an application), -- then copy the icon by entering these commands in Terminal: -- $ cd ~/Library/Scripts/Applications/Finder/open\ in\ TextMate.app/Contents/Resources/ -- $ rm droplet.icns -- $ cp /Applications/TextMate.app/Contents/Resources/TextMate.icns droplet.icns -- $ touch ~/Library/Scripts/Applications/Finder/open\ in\ TextMate.app -- script was opened by click in toolbar on run tell application "Finder" try set currFolder to (folder of the front window as string) on error display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1 end try end tell CD_to(currFolder, false) end run -- script run by draging file/folder to icon on open (theList) CD_to(theList, false) end open -- open the file/folder in TextMate and fill screen on CD_to(theDir, newWindow) try set theDir to quoted form of POSIX path of theDir as string do shell script "open -a TextMate " & theDir --set screen dimension variables set menubarHeight to 22 set projectfolderWidth to 211 set screenWidth to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width") as number set screenHeight to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height") as number --if you plan to use this on just one computer where the screen dimensions won't change, this script will run faster if you just hard code your screen resolution with these two lines: --set screenWidth to 1280 --set screenHeight to 854 tell application "TextMate" to activate if theDir does not end with "/'" then tell application "TextMate" set bounds of window 1 to {0, menubarHeight, screenWidth, screenHeight} end tell else tell application "TextMate" set bounds of window 1 to {projectfolderWidth, menubarHeight, screenWidth, screenHeight} end tell tell application "System Events" keystroke "d" using {control down, option down, command down} keystroke "d" using {control down, option down, command down} end tell end if on error the error_message number the error_number display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1 end try end CD_to