Modifying the .cshrc File

As mentioned above, the .cshrc file in each user’s home directory can be modified to add features to the c-shell environment. Users can define aliases of commonly used commands, add to the search path for executables, perform actions when a new shell is opened, and define environmental and c-shell specific variables automatically. These operations are outlined below. To use any of these in the .cshrc file, simply include it on a new line in the file.

Command Aliases

Aliases can be used to define a shortcut to commonly used commands, or more often, commonly used commands with special options.

alias [shortcut] ‘[command]’

alias lsl ‘ls —al’

Aliases the shortcut designator to the specified command so that when the shortcut designator is typed on the command line the command is executed. Be careful picking already used command names for the shortcut designator. The example given above sets the alias lsl to list the directory in long format.

Search Path

When a command is typed on the command line, the shell searches for the executable matching the command in several directories. This is termed the path in the c-shell. The directories are searched in order and the first match found is used. The main cshrc file defines several directories in the path:

/usr/sbin

/usr/bsd

/sbin

/usr/bin

/bin

/usr/bin/X11

/usr/local/bin

. [the current directory]

If you wish to include other directories in the path, for instance to define your personal bin directory, or to include the bin directory of a new suite of programs, use the following definition:

set path ($path, [path])

set path ($path, /usr/people/mcdermoj/bin/)

Sets the search path to the designated path. $path signifies the previously defined path and is included to ensure that the path that is defined by default remains valid. Omitting the $path variable would mean that no commands would work in the shell since they would not be located.

Startup Commands

To execute a given command (or set of commands) every time a new shell is opened simply include the command on a new line in the .cshrc or .login file. For instance if you have a program which gives a random quote every time it is executed, quoth_i, inclusion of the command in either resource file means that every time a new shell is opened a random quote will be printed at the top of the screen.

Defining Variables

Specific environmental variables are required by some programs. To set environmental variables in the .cshrc file, use the setenv command described above on a new line in the file.

Note: Be careful modifying your startup files, .cshrc and .login. It is possible to add lines which will cause you to exit from the system, crash, or ‘hang’, before you get a command line. In this case you need to contact the administrator who can modify your startup files without invoking them.