-
Website
http://henrik.nyh.se -
Original page
http://henrik.nyh.se/2007/10/open-in-textmate-from-leopard-finder -
Subscribe
All Comments -
Community
-
Top Commenters
-
Craig Jolicoeur
1 comment · 1 points
-
Tobias
2 comments · 2 points
-
Andreas Haller
1 comment · 1 points
-
Thejesh GN
1 comment · 3 points
-
jjinux
2 comments · 1 points
-
-
Popular Threads
With the 'Open in Textmate' I get the following error:
'Can't get selection of application "Finder".
The Open Terminal Here also doesn't work. This error-message is as follows:
'Can't get 'class sdsk' of application "Finder"'
Does anyone have an idea what this error might be? I very much like the idea, but well, unfortunately it doesn't work.
Anyone with Tiger that it does work for?
But thanks for responding anyway, I probably should have mentioned it.
Open
/Applications/Apple Script/Script Editor.appand make a selection in the frontmost Finder window. Try running this in Script Editor (paste, press "Run"):tell application "Finder" to selection. That should show a list like{document file "foo.txt" of folder "Desktop" … of startup disk of application "Finder", document file …}in the lower part of the window. Without a selection, it should be an empty list. Does that not work either?Thank You
'tell application "Finder" to selection' works in script editor to return a list (blank if no selection).
don't know if it helps but running the open in textmate code in it with a selected folder i get:
Can't make alias "my_volume:my_path" into type «class alst».
without a selection i get:
Can't make «class cfol» of window 1 of application "Finder" into type string.
I did a small modification to the icon and the code it now opens the file(s) in TextWrangler instead! It's for us cheapos out there ;-)
<http://fredin.org/david/files/OpenInTextWrangler.app.zip>
Try replacing the original 'run' handler with the following code, which should work around a number of longstanding bugs in AppleScript and Finder.
on run
tell application "Finder"
if selection is {} then
try
set finderSelection to {folder of the front Finder window as alias}
on error number -1700
-- 'as alias' coercion will fail if front window is 'Computer'
-- or if no windows are open and nothing is selected on desktop
beep
return -- nothing to open, so stop here
end try
else
-- various bugs in Finder and AppleScript relating to 'as alias list'
-- coercion and/or using it on 'selection' property, so get a list of
-- Finder references and coerce them one at a time in AppleScript
set finderSelection to selection
repeat with itemRef in finderSelection
set itemRef's contents to itemRef as alias
end repeat
end if
end tell
tm(finderSelection)
end run
HTH
has
(p.s. If you're a Ruby fan, you might like to check out rb-appscript which lets you script applications from Ruby in place of AppleScript - see my sig for links. You still have to deal with application bugs and quirks, of course, but at least you don't have to face the AppleScript language's own bugs and quirks as well.;)
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
Great button! Thanks.
thanks Has and Henrik!
thanks man!
(edit in textmate issue in cyberduck)
http://trac.cyberduck.ch/ticket/1244
http://macromates.com/blog/2007/inputmanagers-o...
You said "I also toggled a flag in the bundle so you don't see the script appear and disappear in the dock when triggered."
Acutally both lselect and OpenTerminalHere icons appear in the dock. I find it quite annoying.
TIA
touch the_scriptin Terminal, or move it to another directory and open it and move it back.Cheers!
Thanks,
Ben
I have been wondering the same thing. ;) I mostly did this on Allan's request, and usually drag to the dock icon myself. I do like the toolbar icon when you want to open the current directory in TextMate, though: clicking the toolbar once is quicker than holding on the proxy icon and then dragging it.
The drag-and-drop functionality of the toolbar icon is more for completeness, really – I'd probably use the dock icon for that since it's a larger target (taller than a toolbar icon, and a mile wide).
I was able to just drag TextWrangler app to the Finder toolbar in Tiger and drag files onto that icon to open the files in TextWranger.. Maybe it's different for TextMate and/or Leopard..;;
The TextMate icon does not allow you to SELECT a file in a Finder window, then *click* the icon to open that file. I find draaaaaging a file to be too fussy a motion, plus the window may begin scrolling. And if you twitch at the wrong time you can release the mouse button and end up dropping the file in the wrong place, etc.
Some might ask, why not just double-click the file you want to open? Because... its type is not associated with TextMate! Usually, I want a web browser to open when I double-click a html file, *sometimes* I want to edit the same file in TextMate. (The same for a .plist file, for example.)
This command makes that a snap! Two clicks! Just fabulous. :)
See this post.
Your script doesn't work in Tiger. But it wasn't that hard to back port it for 10.4.
Great idea! I learned a few new tricks from looking at what you did. Thanks!
Thanks.
Great!!!