Which shell is best for you? Does it matter?

The choice of shell is one of religious fervour for some and a case of indifference for others. Does it matter? Well, it depends how much scripting you do, whether you'll use the better facilities provided by some shells, and possibly your scruples regarding open source software. Thus there is more to shells than what you've been given on your Linux distribution (probably a minimum of bash, csh, tcsh, korn - or rather the pdksh - and zsh). Read on for a quick tour...

The bash shell

The bash shell is pretty customizable and for now, I'll just give a quick flavour of some of the rather cute tricks you can do with it to make your shell environment easier. Perhaps the first thing newbies do is begin to alias their favourite program settings with an easier to remember alternative. Think for example, of the common practice of running several xterms, each one showing the output of various programs such as gcc, pine, latex / dvips, man pages, etc.. It's much easier if you keep a set of colours you like which enable you to quickly identify which terminal is doing what. Now I like to start an xterm with the following rather horrendous set of switches:

kester@linux:~ > xterm -bg black -fg orange -rightbar -title "Orange xterm" +ulc +bdc &

But if you type this command in and type man man, you'll immediately see the benefits of all the switches. xterms give me other nice things like being able to use the mouse wheel to both scroll through my history and (with the alt button pressed) up and down the output of my commands. Very nice so far, but life's too short to remember such things or to even type man xterm to look up such things, so to avoid this I alias the command with a much simpler command by placing the following in my .bashrc file:

alias oterm='xterm -bg black -fg orange -rightbar -title "Orange xterm" +ulc +bdc &'
alias pterm='xterm -bg black -fg orchid -rightbar -title "Purple xterm" +ulc +bdc &'
alias gterm='xterm -bg black -fg green -rightbar -title "Green xterm" +ulc +bdc &'
alias bterm='xterm -bg black -fg dodgerblue -rightbar -title "Blue xterm" +ulc +bdc &'

Which to state the obvious, gives me xterms in the colour I want with all the settings I want by just typing the appropriate alias (e.g. pterm for a purple xterm, and so on).

Almost everyone has a list of their favourite aliases, and it's never too late to discover something new about even such an ancient and venerable piece of kit as the humble xterm by examining closely other people's aliases. It also gives you something of the 'diet' of regular commands used by other people. Always interesting. So, please send yours in (we'll be making a list at some point, and your alias will appear alongside your name to make you an instant star among the Linux loving folk of York!).

Another favourite plaything is the prompt. The prompt's variable name under the bash shell environment is PS1. PS1 can be added to your .bashrc file in just the same way as aliases can or you can type it in directly at the command-line (though of course you won't have it for the next session!). My particular favourite for a while was the following monstrosity, which provided me with a constant reminder of the time in grey, user in purple (useful if you're like me and always using su), and the current working directory in whatever colour the shell foreground is. Thus:

PS1="\[\033[37m\]\$(date +%H:%M)\033[0m\]\[\033[35m\] \u:\033[0m\] \W > "

will give an output of:

23:36 kester: YLUG >

Using the orange terminal. A slight bit of tweaking lets you see the full working directory (pwd) as opposed to the current directory. Simply change the final capital 'W' to lower case, like so:

PS1="\[\033[37m\]\$(date +%H:%M)\033[0m\]\[\033[35m\] \u:\033[0m\] \w > "

which will then produce:

23:36 kester: ~/ArtWork/YLUG >

As always, let me know your own monstrosities and have fun!


Thumbnail for YLUG logo -
	clicking takes you home
Kester Clegg
Last modified: Fri Aug 4 00:04:15 BST 2000