DISQUS

The Pug Automatic: "Open in TextMate" from Leopard Finder

  • Allan Odgaard · 2 years ago
    Thanks — works wonderfully! :)
  • Brandon Mitchell · 2 years ago
    Marvelous! Thank you!
  • Greg · 2 years ago
    Thanks for this!!
  • Pieter Omvlee · 2 years ago
    Very strange, it doesn't work for me.
    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.
  • Henrik N · 2 years ago
    Pieter: I'm on Leopard. Could be that parts of the script are Leopard-only, but I wouldn't think so. I don't have a Tiger installation to test on I'm afraid.

    Anyone with Tiger that it does work for?
  • Pieter Omvlee · 2 years ago
    I am also on Leopard, so that shouldn't be problem.
    But thanks for responding anyway, I probably should have mentioned it.
  • Henrik N · 2 years ago
    Hm. Then I have even less of an idea ;) About the "Open Terminal Here" issue, you should bring that up with the author of that script, though there is certainly a point in mentioning both errors to both of us, in case they suggest some common cause.

    Open /Applications/Apple Script/Script Editor.app and 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?
  • Robert McGovern · 2 years ago
    Just wanted to add my thanks for this. Quite useful.
  • Chris Poirier · 2 years ago
    Great work! Thanks. :-)
  • Thomas Aylott · 2 years ago
    Oh! forgot to say how incredibly awesome the Edit in TextMate thing is. You rock!
  • Stanislav Majerski · 2 years ago
    Fabulaus! Works great, tested with Tiger 10.4.10
    Thank You
  • nay · 2 years ago
    hi there, i've had no luck getting this to run on tiger,
    '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.
  • Johnny · 2 years ago
    Works! Thanks a lot! :-)
  • tench · 2 years ago
    very cool. on my comp, however, the supplied icn images turn out smaller than the rest of the finder toolbar images. how come?
  • Henrik N · 2 years ago
    tench: That sounds familar – I believe I got that effect when I tried to copy icons into the script's info window in Finder. When I replace the .icns inside the application bundle, though, the size is right.
  • tench · 2 years ago
    hm... that doesn't seem to be the problem, because i was replacing the icons precisely within the bundle. in fact, even the original bundle with the original icn file appears small in my finder toolbar, without any intervention on my part. when i click on the icn file, it opens in preview and looks like it's the right size... anyway, this is a great script, i hope i'll figure out the image problem. if anybody else still has the size issue, do let know.
  • Mats · 2 years ago
    Tack så mycket !!!
  • Thomas Aylott · 2 years ago
    You may have to command-click the top-right finder button thing to change to size of the icons in the toolbar. They only look right when at large icon size.
  • tench · 2 years ago
    yup, thomas. the icons only look right with large icon sizes. thanks a lot for the tip.
  • seyDoggy · 2 years ago
    Awesome! Thanks a bunch!
  • seyDoggy · 2 years ago
    Hey is it possible to get this to work in Path Finder?
  • ange · 2 years ago
    Great scirpt!
  • David · 2 years ago
    Hi!

    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>
  • has · 2 years ago
    Pieter: "Very strange, it doesn't work for me."

    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
  • axelk · 2 years ago
    replacing the 'run' code with what has suggested made it work for me on Tiger. I ran into 'alias list' problems.
    Great button! Thanks.
  • nay · 2 years ago
    awesome! worked for me too.
    thanks Has and Henrik!
  • Daniel Niculescu Logofatu · 2 years ago
    works fine for me right out of the box. on tiger 10.4.9 (hackintosh actualy).
    thanks man!
  • Collin Allen · 2 years ago
    I built a toolbar-style custom icon I thought I'd share: Preview | Download
  • Yudi · 2 years ago
    good to see it does not bother with the input manager issue :-)

    (edit in textmate issue in cyberduck)
    http://trac.cyberduck.ch/ticket/1244

    http://macromates.com/blog/2007/inputmanagers-o...
  • Ludovic Kuty · 2 years ago
    I am interested in the method you used to prevent an icon from popping in the dock.
    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
  • Henrik N · 2 years ago
    Ludovic: Yeah, I have both of them modified locally to stay out of the dock. Modify like this. The plist is apparently cached, so for it to take you have to reboot, or touch the_script in Terminal, or move it to another directory and open it and move it back.
  • Armon · 2 years ago
    Thanks a lot! Very useful. I like the grayscale icon more than the textmate icon, its cleaner looking. If anyones wondering, it works fine on a clean Leopard install.
  • Travis Bell · 2 years ago
    User "has", thanks for the modification. That fixed it for me in Tiger as well.

    Cheers!
  • Robert Nyman · 2 years ago
    Works great! Thanks!
  • Ben Long · 2 years ago
    Hi, I'm curious how this is different from simply dragging the Textmate application icon to the finder toolbar?

    Thanks,
    Ben
  • Henrik N · 2 years ago
    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).
  • Sam · 2 years ago
    I too would love a Path Finder option for this handy script. I've tried myself but lack the chops to actually make it work. Anyone want to tackle this?
  • Sang · 2 years ago
    hmm.. couldn't you just drag TextMate icon to the Finder toolbar instead?
    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..;;
  • Henrik N · 2 years ago
    Sang: You could, but then you couldn't (to my knowledge) change the icon without changing it for the entire app, and you couldn't click the toolbar item to open the current directory in TextMate. See my comment above.
  • Craig Anderson · 2 years ago
    Works great, but is there any way of attaching this to a hot key?
  • Geir Aalberg · 2 years ago
    To change the icon so it looks better in Tiger/small size, just use "Get info" on the script and change the icon thumbnail there to something more appropriate (I used the Textmate.app icon).
  • Eric O'Brien · 1 year ago
    "How this is different from simply dragging the Textmate application icon to the finder toolbar?"

    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. :)
  • Henrik N · 1 year ago
    Oops, accidentally removed a comment by Ken:


    Btw, by looking at the screenshot, it seems like you have a "generic" toolbar icon background. I've been looking for that background, so i can customized my Finder toolbar icons. Where do I find it?

    thanks a lot


    See this post.
  • Thiemo Gillissen · 1 year ago
    brilliant! love it. thanks a lot.
  • Olof · 1 year ago
    Grymt!
  • Christopher Webb · 1 year ago
    What a great bit of code! Thank you for making it available to all!
  • Isaac Schlueter · 1 year ago
    Henrik,

    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!
  • Ronny · 1 year ago
    Great work. Installed it, and it works just fine. Thx a lot!
  • Maddog · 1 year ago
    Totally Rad. Thanks man!
  • reremoon · 1 year ago
    Any idea to make this cool extension work with pathfinder instead of the finder ? thanks !
  • reremoon · 1 year ago
    Ok i just fould it here. Thanks to Circle Six Design !
  • Eirik · 1 year ago
    Awesome!
    Thanks.
  • Russ · 1 year ago
    Appears to be broken with the latest release of textmate, it crashes textmate and script gives error connection invalid. Use to work a week ago until I updated textmate.
  • Deelip K · 11 months ago
    Awesome.
  • khairyelsayed · 2 months ago
    Thank you,

    Great!!!