Open Terminal Here is an AppleScript by Marc Liyanage which allows to open a new Terminal window and `
cd` to the current Finder location by a mere click. This is delightful for heavy Terminal users.
Now that Leopard’s Terminal finally has tabs there has been a modification of the original script to take advantage of those when your front-most shell is busy (running
vi for example). Better integration with the Finder also showed through better icons.
However I still did not find the ease I had with OnMyCommand and iTerm scripts: with a right click I could open a new window or a new tab, in the current or in the parent Finder’s directory. Using those scripts in Leopard was less than ideal since the menu of OnMyCommand is buried under the “More” item in the Finder’s contextual menu and the scripts had to be rewritten for Apple’s Terminal which is more robust than iTerm. So I decided to improve on all the work other already did and modify Open Terminal Here. Using a method wonderfully described by jobu at MacScripter I was able to detect key-down events at the start of the application and used them to modify the behavior of the script. Now:
- Clicking the application icon creates a new Terminal at the Finder’s location (i.e. the old behavior)
- ⌘ + Clicking opens a new tab in the frontmost Terminal instead of opening a new window
- ⌥ + Clicking runs the
cdcommand in the frontmost Terminal window if it is not busy. Otherwise it opens a new window/tab (depending on the state of ⌘)
Of course there is still plenty of room for improvement. The source is freely available for download in the form of an XCode project. Please modify, tweak, improve, and make it better than I ever could.
One last tip, which you probably already know if you read the post through here but there’s no harm in repeating. To do the reverse operation (i.e. open a Finder window in the current Terminal directory) just issue the command
Sweet ;) This replaces the page titled From Finder to Terminal, and back again from my old site, which had less information anyway (in addition to being a lame reference to a nonetheless great book).