tags:

views:

1839

answers:

5

Is it possible to open a terminal window with 3 tabs. Each tab should have different path.

Example:

Tab1: /etc
Tab2: /bin
Tab3: /www/ tail -f file.txt
A: 

Open the tabs you want and set each one up as you wish, i.e. in tab 1, cd /etc, tab 2 cd /bin and so on. Now go to Window > Save Windows as Group. Click the checkbox 'Use window group when Terminal starts' and hey presto!

Gav
Though I don't think you can set tabs to actually execute a specific command (i.e. tail, as in the example). Is this possible?
rledley
+1  A: 

I suspect you can control commands to be executed too. One of the programs I use creates a single-tab terminal window and arranges to execute a profile-setting script before continuing to the command prompt - the same should be feasible for a multi-tab terminal. The file is a MacOS X properties XML file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
<plist version="1.0">
<dict>
    <key>CommandString</key>
    <string>. /Applications/IBM/informix/demo/server/profile_settings</string>
    <key>FontAntialias</key>
    <false/>
    <key>RunCommandAsShell</key>
    <false/>
    <key>ShowShellCommandInTitle</key>
    <true/>
    <key>TerminalType</key>
    <string>xterm</string>
    <key>WindowTitle</key>
    <string>IDS Command Window</string>
    <key>name</key>
    <string>IDS Command Window</string>
    <key>type</key>
    <string>Window Settings</string>
</dict>
</plist>

You can click on it and the terminal window is launched, the profile settings are set, and then you have a command prompt to type at. Presumably, changing the 'dot' command into the 'tail' command of the question would work; it might be that the 'RunCommandAsShell' key set to '<true\>' would replace the normal shell with the command - which is perhaps more appropriate for the question.

Jonathan Leffler
+2  A: 

I suggest the use if iTerm instead of Terminal. If only because it is more configurable. You can script it, but more important to you is that you can create a bookmark folder (one for each tab) and then "open in tabs" which will give you the behavior you seek.

John K
Thanks man! This is it!
xpepermint
+6  A: 

You can do what you wish from within Terminal.

If in Terminal preferences (Settings tab) you create a new profile (or copy one with Duplicate Settings), you can then set each profile to run a command on startup (the "Shell" subgroup within the profile).

Then setup your tabs by using the Shell > New Tab menu to create the new tabs from each of the specific profiles that you created for the three different executables.

Then do the Save Window Group to save the group of tabs (and it will save their profiles as well).

Jason King
+5  A: 

This is absolutely possible, but it will take some work on your part. The first thing you need is to set up each window/tab you want in your Settings: alt text

I have 4 tabs that I open automagically every time I open Terminal. DB Shell, Editor, Server, and Shell. These are all within the Sasquatch (don't ask) project, thus the naming. Each of these should then have a unique command associated with them: alt text

In this case, I'm executing vim. If you happen to have a specific directory you'd like to start off in, you can use something like vim ~/projects/main/. Really whatever you want to go in there is the command the shell will execute when it opens. Now you need to open all your windows/tabs:

  1. Close everything.
  2. Open a new window for each of your profiles.
    • Go to the Shell menu => New Tab/New Window => Select the profile you created above.
    • Repeat for each window or tab you want.
  3. Once you have all of your windows and/or tabs open, save them as a Window Group.
    • Go to the Window menu => Save Window As Group....
    • Give your Window Group a name (this is helpful later).
    • If you want this group to open every time you open Terminal, check the box at the bottom of this screen, and then hit save.
  4. Close out of all of your Windows/Tabs (time to test it!).
  5. Open your new Window Group.
    • Go to the Window menu => Open Window Group => Select the group you just made.

This should pop up all the windows you just had, in the same position. Each of the commands you set up in Settings should be launched in their respective tabs.

Jack M.