
That was actually the first post in a series (of two). This one opens a new
TextMate window on the selected item (if there’s a single item selected), or
the current folder otherwise. This makes the script a lot shorter (that and
there being a simple command-line TextMate launcher that I can use).
The instructions are the same as last time; save it as an application
somewhere you can find it, and call it “TextMate Here”. Find it with the
Finder, copy and paste TextMate’s icon onto it, and drag it up into your
Finder toolbar.
If you have TextMate installed someplace strange (or have an old enough one
that it doesn’t have the `mate` command in it) it will break; if this
happens, you get to keep both pieces.
Here’s the script:
on currentFolder()
tell application “Finder”
try
return POSIX path of (front window’s folder as text)
on error
return null
end try
end tell
end currentFolder
on selectedItem()
tell application “Finder”
try
get the selection
return POSIX path of (the result’s first item as text)
end try
end tell
return currentFolder()
end selectedItem
do shell script “/Applications/TextMate.app/Contents/Resources/mate ‘” & selectedItem() & “‘”
{: lang=applescript }
Feedback, improvements, etc. still welcome.