Ubuntu: Opening multiple tabs with gnome-terminal

Question:

I'm trying to create a command that will open 3 services from the Rails stack, rails s, spork, and autotest. I can run these commands individually by opening 3 terminals, going to the app folder and running them. I can even open 3 new tabs and run the commands on each.

The problem is that they fail when I try to open the tabs via gnome-terminal like so:

Solution:2

Invoking gnome-terminal three times and stringing the commands together with &&won't work, and the tabs won't appear in the same terminal, and indeed you will have to quit the first terminal for the next to appear.

The way to make sure all your tabs open in one instance of gnome-terminal all at the same time is to use the --tab-with-profile=PROFILENAME switch. In the command below you can leave the first command as gnome-terminal --tab as that it is the first window to be generated; now all you need to know is which profile you are using and you can use --tab-with-profile=YourProfile to invoke the other commands and they will all appear at once in the original terminal opened.

(For future readers: substitute the program names given after -e to test out the command line given here; remember your targets for -e must be installed and in $PATH; for things not in $PATH use an absolute path such as, for example, /opt/mike/program)

Remember to specify the actual profile you are using for the --tab-with-profile switches. The first invocation of gnome-terminal must use --tab and all the rest --tab-with-profile. With this method it should be possible to open a large number of tabs all in the same instance of gnome-terminal.

Find the profile you are currently using by right clicking in gnome-terminal and look at profiles and there will be a marker on the one you are currently using:

Go to Profile preferences for more information and to check the name of the profile.

If you have trouble launching your programs with gnome-terminal, either add the location to $PATH, or make a symlink and place it in a $PATH location, or (what was very useful here): create a simple bash wrapper script and call that in the gnome-terminal command line above. (You must call it with an absolute path: i.e. /location/of/script and not just the name of it.)

As an example:

#!/bin/bash cd $HOME/.rvm/gems/ruby-2.0.0-p0/bin spork exit 0

Then name the script, make it executable and call it in the gnome-terminal command line above. Do this for all the non repo programs that are problematic.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com