Amazon

Monday, February 18, 2008

New Terminal Tab Script for Leopard

My favorite tool for quickly opening a terminal window to a particular directory under Tiger is Marc Liyanage's Open Terminal Here toolbar script.

Now that I am running Leopard, most times I find myself wanting to open a new tab instead. This enhanced toolbar script fits bill, if I am staring at the folder within the Finder.

But, most of the time I find myself staring at a Terminal window, already in the directory I want the new tab to be in. Switching to the Finder in order to find the folder and then clicking on a toolbar button just doesn't cut it for me.

So, based on Solomon White's work, I came up with a similar Ruby script. Under tcsh, I set up an alias named nt pointing to the script. When invoked without any arguments, the script opens a new tab pointing to the same directory as the current one. If one or more directory paths are supplied as arguments, a new tab is opened for each one, placed into the corresponding directory.

The script works fine for me under 10.5.2. Feel free to download it for yourself. Note that the rb-appscript gem needs to be installed as a prerequisite.

2 comments:

ReinH said...

Thanks for this!

Made a minor modification of your script to open directories under the current directory passed as args instead of requiring full paths. These two lines below replace the original line 8 (I don't know how to get <code> formatting):

pwd = Dir.pwd

working_dirs = (ARGV.length > 0) ? ARGV.map{ |dir| File.join(pwd, dir) } : [pwd]

Eric said...

I found this to be too slow for my uses, so I wrote up a shell script that invokes osascript directly.

http://gist.github.com/35556