A. Appendix: Command Examples

The following will include some examples of things that can be done with Multi Gnome Terminal's Edit Commands feature. The examples below represent the "command" input field (third field) at the top of the Edit Commands Window. You will have to supply your own Command name, and path if wanted. Note that some of the examples are included with the mgt-helper script.

Starting shells:

Example A-1. Start a login shell

The most typical usage is to start a normal, interactive shell. The --login bash command line option above is optional.

  bash --login

Example A-2. Start a remote shell with ssh

But we can also start a remote shell on another host:

  ssh some_host.example.com

Example A-3. Start a mail reader

We can also start any text based program automatically, like a mail reader, or news reader:


Example A-4. Specify a specific mailbox

You can watch multiple mailboxes with multiple instances of your mail reader. This way the Tab labels will change color to alert you to new mail in that mail box.

  mutt -f ~/Mail/inbox

And another command for another mailbox:

  mutt -f ~/Mail/multignometerm-usability

We could get really fancy and create a special Class, maybe titled "mail", and create a custom start-up Tab for each mailbox we want to access.

Example A-5. Start a text web browser

  w3m ~/my_bookmarks

In fact, you could create a sub-menu with your "favorite" links all in their own sub-menu:

w3m/user friendly

Example A-6. Start a remote shell and start a program on the remote host

  ssh -t some_host.example.com pine

Example A-7. 'watch' netstat connections

  watch netstat -tn

Example A-8. Watch the "message" log

  tail -f /var/log/messages

The Tab labels will also change colors every time a new entry is made to the log.

To this point, all our examples have been single shell commands with arguments (though the arguments in some cases are other commands). If we want to combine commands for more complex usage, like piping ps to less:

  /bin/ps ax | less

then it is useful to put these types of commands in a shell script, and then invoke the script from Edit Commands. Much more can be done this way. Alternately, complex commands like the above example can be executed successfully from Edit Commands with the help of mgt-helper and the "-x" option. Example:

  mgt-helper -x /bin/ps ax | less

Some other, "nicer" ideas:

Example A-9. A Google search


  read -e -p "search google/linux for: " search_str
  [ -z "$search_str" ] && exit
  $txt_browser \

This uses the shell "read" command to get user input, which is passed to a text web browser. If the user enters nothing, or after the web browser exits, then the script exits also, effectively closing the Tab. (The google search parameters also include some personal preferences that might be customized as well. The above example is available with mgt-helper as mgt-helper -lg.)

Example A-10. Look up a word in a Dictionary

  read -e -p "Look up: " word
  [ -z "$word" ] && exit
  $txt_browser "http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va\
   =$(echo "$word" | sed 's/ /+/')"

This looks up any word in the Merriam-Webster on line dictionary, also using read and a text browser, like above. (The above example is available with mgt-helper as mgt-helper -l.)

Example A-11. A better netstat watcher

Above we had an example of watch netstat -tn that displays a continually self updating display of all our network connections. But watch wants to put a clock on the screen, and as it updates the Tab titles alternate from blue to red every 2 seconds as the screen updates. Very annoying IMO!

So here is a short script to do most of the same thing. It just writes the netstat output to a file, and only dumps this file to screen when and if the netstat output changes. It also uses some filters to eliminate some things we (errr, I) did not want to be bothered with (e.g. CLOSE_WAIT condition, see the netstat man page).

  # display netstat output only if it changes

   command="netstat -tn |grep -v \"$exclude\""
   eval $command |tee $tmp_save.sav
   while :; do 
     eval $command > $tmp_file.tmp
     ! diff $tmp_file.tmp $tmp_save.sav && clear && cat $tmp_file.tmp |tee $tmp_save.sav
     sleep 2

Now the Tab title will only change color when the connections change, and we are alerted accordingly.

Example A-12. Starting with a Split Tab

To have Multi Gnome Terminal start with a split Tab, create a short script like below. Name it something like add-htab.sh.

   multi-gnome-terminal --add-tab --hsplit

Now go into Edit Commands, and add a new startup Tab (from the second tab). Use add-htab.sh as the command to open the Tab. Save and apply changes, and make sure "Don't open startup tabs" is unchecked. Now, when Multi Gnome Terminal is started, it will be started with a split window. Remember too, you can have different startup command configurations for different classes.

Example A-13. Having specific HISTORY files for Tabs

It would be nice if Multi Gnome Terminal could save the bash (or other shell) history for each Tab. So when you opened a new Tab, there is only history from your last session in that Tab. But this can be done with a simple shell script quite easily. Create a script like below, and name it something like bash_wrap.sh:


    if [ "$1" == "" ]
    export HISTFILE=$HOME/.bash_history$BEXT
    exec bash --login

Put this script in your PATH somewhere (e.g. /usr/local/bin/). Now edit your custom Multi Gnome Terminal Commands to use the name of this script, instead of just "bash", and some unique argument for the script:

  Name          Path            Command
  Shell1        None          bash_wrap.sh  myshell1
  Shell2        None          bash_wrap.sh  myshell2
  Shell3        None          bash_wrap.sh  myshell3

What identifier you use for the argument (e.g myshell1), is not important, just so it is unique. Now bash will load that history file whenever that Tab is opened. (The above functionality is available with mgt-helper as mgt-helper -h EXT.)


Maybe you prefer just typing simple commands rather than going through the GUI, or defining a keyboard shortcut? Sometimes this is simpler. Some ideas using bash "aliases" ...

A simple bash alias to just create a new Tab in the current Window:

  alias m="multi-gnome-terminal  --add-tab"

Now, create a Tab and running the vim editor at the same time:

  alias me="multi-gnome-terminal  --add-tab  --tname=Vim  -x vim"

The Tab, of course, closes neatly whenever you exit vim.

Now, a open a man page in its own Tab:

  alias mm="multi-gnome-terminal  --add-tab  --tname=Man  -x  /usr/bin/man"

Maybe we want to work in one terminal, and be able to read the man page in the same Window at the same time. So we will do the same here, except just split the current Tab:

  alias mmh="multi-gnome-terminal  --hsplit  -x /usr/bin/man"

Using shell functions, gives even more flexibility:

  mm () {
   multi-gnome-terminal --add-tab --tname "Man ${args[$(($# - 1))]}" -x /usr/bin/man $*
   unset args

The only real difference between this and the previous bash "mm" alias, is that the Tab label now shows the name of the man page, instead of just "Man" (and allows for things like "man 5 crontab").

Maybe you have better ideas ;-)


If you have any cool command tricks, please submit to: .