Opening multiple command prompts with multiple commands in each, using Ubuntu 10.04
Before getting all stinky in development mode, it's usually necessary to open a number of different terminals: One for the server, another for Spork, another for autotest, another for for Compass, and another to tail my development log. Prior to setting this up I'd just do shift+ctrl+t to open a new tab followed by the appropriate command in each terminal to begin each process, but as an exercise in learning more about Bash and the terminal I decided to try to automate some of it. I'm sure there are a number of better ways to automate this process, but to paraphrase the rifleman's creed: This one is mine. It should work fine for any flavor of Ubuntu, though my particular version is 10.04.
The first thing to do is open up your terminal with a good set of default tabs. To open the tabs I need and get the processes I want started, I used:
$ gnome-terminal --tab -e "bash -c 'rails server'" --tab -e "bash -c 'spork'" --tab -e "bash -c 'autotest'" --tab -e "bash -c 'compass watch'" --tab -e 'tail -f log/development.log'
You should be able to cut and paste this directly if you use the same tabs, but it may make more sense in your own implementation to try just a couple of these commands at first. The next step is to create a file to store this tab configuration in. I'm not sure if it was the wisest choice, by I named my configuration file "railstabs," and put it into the root directory of a Rails 3 application I'm building called Skygodlin.
Now this may not make a whole lot of sense, but you will want to close all of your older terminals at this point. Just trust me on this. Leave only the terminal with the needed tabs open. And then open a new tab in that terminal and use this command to save your configuration:
$ gnome-terminal --save-config=/home/frederick/Dorpbox/skygodlin/railstabs
#Written by GNOME Terminal 2.30.2[GNOME Terminal Configuration]Version=1CompatVersion=1FactoryEnabled=trueWindows=Window0;[Window0]MenubarVisible=trueRole=gnome-terminal-window-2754--618914462-1298626727ActiveTerminal=Terminal0x83fea18Geometry=80x24+0+239Terminals=Terminal0x8371800;Terminal0x838eda0;Terminal0x837bc00;Terminal0x83c1468;Terminal0x83fea18;[Terminal0x8371800]ProfileID=DefaultCommand='bash' '-c' 'autotest'WorkingDirectory=/home/frederick/Dropbox/skygodlinZoom=1Width=80Height=24[Terminal0x838eda0]ProfileID=DefaultCommand='bash' '-c' 'compass watch'WorkingDirectory=/home/frederick/Dropbox/skygodlinZoom=1Width=80Height=24[Terminal0x837bc00]ProfileID=DefaultCommand='tail' '-f' 'log/development.log'WorkingDirectory=/home/frederick/Dropbox/skygodlinZoom=1Width=80Height=24[Terminal0x83c1468]ProfileID=DefaultCommand='bash' '-c' 'spork'WorkingDirectory=/home/frederick/Dropbox/skygodlinZoom=1Width=80Height=24[Terminal0x83fea18]ProfileID=DefaultCommand='bash' '-c' 'rails server'WorkingDirectory=/home/frederick/Dropbox/skygodlinZoom=1Width=80Height=24
$ gnome-terminal --load-config=/home/frederick/Dorpbox/skygodlin/railstabs
# Alias definitions.# You may want to put all your additions into a separate file like# ~/.bash_aliases, instead of adding them here directly.# See /usr/share/doc/bash-doc/examples in the bash-doc package.# if [ -f ~/.bash_aliases ]; then# . ~/.bash_aliases# fi
# Alias definitions.# You may want to put all your additions into a separate file like# ~/.bash_aliases, instead of adding them here directly.# See /usr/share/doc/bash-doc/examples in the bash-doc package.if [ -f ~/.bash_aliases ]; then. ~/.bash_aliasesfi
alias gemi='gem install'alias rs='rails server'alias skygodlin='gnome-terminal --load-config=/home/frederick/Dropbox/skygodlin/railstabs'
$ skygodlin
