Ubuntu – Opening multiple tabs with gnome-terminal

gnome-terminal

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:

gnome-terminal --tab --title="rails s" -e "rails s" --tab --title="spork" -e "spork" --tab --title="autotest" -e "autotest"

Error (for spork and autotest):

There was an error creating the child process for this terminal
Failed to execute child process "spork" (No such file or directory)

Surprisingly it does work for 'rails s' (the tab shows the server running).

Any ideas?

Best Answer

Below is an answer from stackoverflow.com

  1. Add a eval "$BASH_POST_RC" to the end of your .bashrc

  2. Set the BASH_POST_RC environment variable for each tab to that command you like to execute, e.g.: gnome-terminal --working-directory="/home/zardoz/projects/my_rails_app" --tab -e 'bash -c "export BASH_POST_RC=\"rails server\"; exec bash"' --tab -e 'bash -c "export BASH_POST_RC=\"autotest\"; exec bash"'