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.
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:
- Open the Script Editor application
- Past in the source
- Save it
- Then chose save as
- Selected File Format of “Application”
- 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:
- Go to Applications
- Navigate to iTerm
- Select the More Info… button
- Find your iTermHere.app and do the same
- Click the small icon at the top of the iTerm more info window and click cmd-c (apple-c, the shortcut to copy text)
- 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.