This following will include some examples of things that can be done with Multi Gnome Terminal's Edit Commands feature. The following examples are the "command" input field (third field) at the top of the Window. You will have to supply your own Command name, and path if wanted.
Starting shells:
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/freshmeat
w3m/slashdot
w3m/sourceforge
w3m/user friendly
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, 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.
Some ideas:
Example A-9. A Google search
#!/bin/sh txt_browser=w3m read -e -p "search google for: " search_str [ -z "$search_str" ] && exit $txt_browser \ "http://www.google.com/linux?num=50&restrict=linux&\ hl=en&lr=lang_en&q=%22$search_str%22&btnG=Google+Search" |
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.)
Example A-10. Look up a word in a Dictionary
#!/bin/sh txt_browser=w3m 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.
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).
#!/bin/sh # display netstat output only if it changes tmp_file=/tmp/_netstat exclude='127\.0\.0.*127\.0\.0\|_WAIT' 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 done |
Now the Tab title will only change color when the connections change, and we are alerted accordingly.
Example A-12. Starting with 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.
#!/bin/sh multi-gnome-terminal --add-tab --hsplit |
Now go into Edit Commands, and add a new startup Tab (lower listbox). 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 commands for different classes.
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" |
Maybe you have better ideas ;-)
If you have any cool command tricks, please submit to: <multignometerm-devel@lists.sourceforge.net>.