Back to table of contents

Customising the C Shell

Christopher Aubergine Fraser

Preamble

This section covers the minimum you will need to know to customise your UNIX environment, specifically the C Shell (csh). For more information we recommend you read the csh manual page (type man csh). The chapter Getting to Know Your Shell contains lots more information about customising your shell, in somewhat heavier detail.

.cshrc

There will be a file called .cshrc in your home directory. (If there isn't, talk to the technical support desk.) If you looked through it with less, like so

charlie:~ :1 > less .cshrc

You'd see a list of commands, which are probably unfamiliar.

This part of TFM asks you to change your .cshrc. Because .cshrc determines where UNIX looks for commands like ls (as well as other, equally important things it would be annoying to break), it would be wise to make a backup copy before changing the file, like so

charlie:~ :1 > cp .cshrc .cshrc.orig

If something terrible happensyou can restore your original with:

charlie:~ :1 > /bin/mv -f ~/.cshrc.orig ~/.cshrc

You can edit your .cshrc using Vi. If you only want to append a new command to the file, you can also use cat >> (type CTRLD when you're finish adding things).

charlie:~ :2 > cat >> .cshrc
cookie
^D
charlie:~ :3 > 

This adds cookie to the end of your .cshrc; cookie is a program for printing small gem of wisdom and wit; you now get one each time you log in.

Note: changes to your .cshrc have no effect until you log in again, or pretend you've done so by executing22.1 csh.

charlie:~ :2 > exec csh

Environment Variables

Many programs use Environment Variables to allow you to customise them. In fact, much of the behaviour of csh is determined by the way they are set. You can list the values of all environment variables with the env command. You can print the value of a specific environment variable by using echo. The following will print the value of the PATH variable.

charlie:~ :2 > echo $PATH

PATH is a colon seperated list of directories that should be searched to find commands. You should only ever want to add additional direcories to PATH. The following will add a directory called bin in your home directory to the list.

charlie:~ :2 > setenv PATH ${PATH}:~/bin

If you put executable commands, like useful shell scripts or programs you have compiled, in bin, csh can now find them without being given their full path name. There are examples of adding to PATH in the default .cshrc.

One environment variable that people seem to take much joy in changing is prompt, because it determines what the prompt looks like, and consequently affecting some sort of self congratulatory aura22.2.

charlie:~ :2 > set prompt="You're Ugly > "

The variable TERM specifies your terminal type. If you're using a workstation it's value will probably be xterm. If you're using a PC in the Sun labs it will probably be network. When you log into some systems, you'll be asked for your terminal type; if you get it wrong, you can change it with setenv TERM. For example, to change to a vt100 terminal type

charlie:~ :3 >  setenv TERM vt100

Any of those commands can also be put in your .cshrc file, to save typing. (For instance, you can have your prompt automatically set by .cshrc.22.3)

Aliases

Aliases let you abbreviate commands, and in a vague sense introduce new ones. The following creates a command called splat.

charlie:~ :4 > alias splat echo "Thud crunch bang"
charlie:~ :5 > splat
Thud crunch bang

There are a couple of aliases already in .cshrc.

Back to table of contents