Terminal: Window group with commands

Hi, how can I set up a Terminal window group that executes a different command for each window?

What I'm trying to do is restore an array of Terminal instances each pointing to a different location when Terminal opens (so one window should execute "cd x," the next "cd x/src," etc.).

With Tiger I could create a .term file and set an "ExecutionString" (that's how commands were labeled in the .term file format) property for each window, but with SL I'm only able to create one shell command in Preferences|Settings that is executed by all Terminal windows in the group.

So basically, how can I get Terminal to remember a group of windows and their associated file system locations?

I've spent a few hours searching and trying stuff without success. The window groups are stored in Terminal's .plist file so I opened it with Property List Editor and see the Window Groups stored in there but no properties resembling a command for each group.

Thanks!

MBP, Mac OS X (10.6), non

Posted on Sep 5, 2009 3:51 AM

Reply
2 replies

Oct 7, 2009 11:36 AM in response to ffredburger

neenach2002 is basically correct on this one; this post got me pointed in the correct direction. I've gone a little farther to suit my needs (and answer your question directly), so I figured I'd post my results:

First, create a file called "~/window1.bashrc" and place the following in it:
export MYHOME=/Volumes
cd ${MYHOME}

Next, go to Terminal -> Preferences -> Settings. Create a new profile called "MyProfile_Window1" based on one you like, then go to the Shell button, and type "bash --init-file ~/window1.bashrc" (without quotes) into the filed labeled "Run command." Be sure the check box next to it is checked.

Repeat for as many windows as you want, changing your label to Window2, Window3, etc. Be sure you have created the associated ~/window2.bashrc, ~/window3.bashrc, etc also.

You should now be able to open a new window or a new tab via Shell -> New Window -> MyProfile_Window1 or Shell -> New Tab -> MyProfile_Window1, and it should go directly to the directory you want.

Once you have used the menu options above to launch all your windows, save THAT as your window group via Window -> Save windows as group, and under Terminal -> Preferences -> Startup, be sure your newly saved window group is set to launch.

Hope it helps!

- Kevin

PS: If you would like to use this to attach to multiple servers, you can do the same thing by just launching a shell script that performs an SSH to the appropriate server. To take it one step further, consider using the unix "screen" utility to allow you to instantly reconnect to a dropped setup! I think I'll write a User Tip for this - it's a very handy setup!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal: Window group with commands

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.