Open iTerm Here

I've been using iTerm for over a year now. I like it over Terminal for a few reasons, but primarily because it supports multiple frames. This makes my workflow easier as I can see everything on a single screen and can easily navigate from one frame to the other without reaching for the mouse. I've additionally abandoned MacVim for Vim. Now, I can do most everything I need in a single, maximized, iTerm window. But I get annoyed with opening iTerm and having to navigate to the directory of my current desire. Most of the time, I am already browsing the desired directory in Finder as I begin a hacking session.

What is a guy to do?


AppleScript to the rescue

I created an AppleScript app based on work from a couple of other folks, whom I've given attribution. The AppleScript launches iTerm and changes to whatever directory was active in Finder. If iTerm is running, the script opens a new terminal. If iTerm is not running, the script launches it and changes directories accordingly.

Screen shot 2011-02-26 at 3.24.41 PM



You can use the script for yourself.
  1. Paste it into the Script Editor application and save it as an application
  2. In Finder, navigate to the application and drag it to the Finder bar
  3. You can now click the button and it will open the foremost directory in Finder
  4. Or you can drag and drop folders onto the icon
  5. Locate iTerm and Select the More Info... button
  6. Locate your new app and Select the More Info... button
  7. Copy the small icon from the top-left of the iTem Info window
  8. Paste it onto the small icon of your app's Info Window

3 comments:

  1. Thanks to Enrique Comba for tips on bashmarks. I added them to my bash_conf repo on github.

    https://github.com/DocOnDev/bash_conf

    ReplyDelete
  2. Okay, Thanks,
    I not even installed the script, but I just googled 'open iTerm here' and BOOM, I was here..
    That's the power of now.

    Thanks.

    ReplyDelete
  3. If the target directory has funny characters in its path, for example spaces, this will not work properly. The fix is to encapsulate the variable "theDir" in double quotes like so:

    write text "cd \"" & thePath & "\"; clear"

    In the "tell myTerm" section.

    Otherwise this is a really neat script. Thank you for that!

    ReplyDelete