Mac · TechIt

Mac : Open Terminal/iTerm here

Using Mac OS X and browsing the file system with ‘Finder’, I often want to open Terminal or iTerm and have the default path set to the current Finder folder.

Firstly Terminal. I found a script called ‘Open Terminal Here’ at http://jo.irisson.free.fr/?p=59

This seems to suffer from an issue where two windows are opened if Terminal was not already running.

Then I started using iTerm, it has a few more/different options than Terminal. For it I found a script ‘Open iTerm Here’ at http://snippets.dzone.com/posts/show/961

This seems to suffer from a similiar issue to above, where two tabs in a new iTerm window are opened if iTerm was not already running. I tried to modify it (my first apple script attempt) but managed only to get two windows open instead of a single window with two tabs.

Then I found an update to the Open iTerm Here script at http://www.danns.co.uk/node/226

(edit that link is dead a while now but the page was thankfully caught on the Internet archive here)

This version successfully solves the issue of the two tabs. If you are a Terminal user, I imagine it should be easy to apply the patch to the Terminal Here script, or just use this script and have it invoke Terminal instead of iTerm.

Finally, to use the script you then need to save it as an executable app. This is fairly straightforward:

  1. Open the Script Editor application
  2. Past in the source
  3. Save it
  4. Then chose save as
  5. Selected File Format of “Application”
  6. Save it again

You can now use QuickSilver or Silverlight to invoke the script.

However, I wanted to find out if I could add a button to Finder that could be clicked to run it. I eventually found out how to do this and here is how. You can simply drag the script .app file onto the top of the Finder application, and a button is created for it there.

So, when looking at a folder, just click the new button you created and a new iTerm is opened at the current path.

Lastly, I wanted to change the icon from the default. I wanted to use the iTerm icon. To do this, follow these steps to copy and paste the icon from the iTerm application:

  1. Go to Applications
  2. Navigate to iTerm
  3. Select the More Info… button
  4. Find your iTermHere.app and do the same
  5. Click the small icon at the top of the iTerm more info window and click cmd-c (apple-c, the shortcut to copy text)
  6. Click the small icon at the top of the iTermHere.app more info window and paste! (apple-v)

That’s it, you now have the script as an app, with a button in the Finder windows, and a nice iTerm icon.

Many thanks to all the folks involved in creating and refining these scripts I found, as linked to above.

Enjoy.

Advertisements

2 thoughts on “Mac : Open Terminal/iTerm here

  1. Thanks.

    Now I run this application on Mac OS X 10.6. Desktop has four spaces as using “expose/space”.app. There is a problem. Do as follow you will see: open a iTerm window in #1 space, change space to #2 and open Finder, click OpeniTermHere button on Finder. You can find that it opens a new iterm tab in #1 space. But I want to open a new iterm window in #2 space.

    Do you have method to do it?

    Thanks again

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s