Next | Prev | Up | Top | Contents | Index

C Shell Configuration Files

When a C shell user logs in to the system, three startup files are executed in the following order:

  1. The /etc/cshrc file.

    This is an ASCII text file that contains commands and shell procedures, and sets environment variables that are appropriate for all users on the system. This file is executed by the login process.

    A sample /etc/cshrc is shown below:

    # default settings for all users

    # loaded <<before>> $HOME/.cshrc

    umask 022

    if ($?prompt) cat /etc/motd

    set mail=$MAIL

    if ( { /bin/mail -e } ) then

    echo 'You have mail.'

    endif

    In the example, several commands are executed:

  1. The individual user's .cshrc.

    This file is similar to /etc/cshrc, but is kept in the user's home directory. The .cshrc file can contain additional commands and variables that further customize a user's environment. For example, use this file to set the shell prompt for the user. The .cshrc file is executed whenever a user spawns a subshell. A sample .cshrc is shown below:

    set prompt = "Get back to work: "

    set filec

    set history = 20

    In this example, the user's prompt is set, automatic filename completion is turned on, and the length of the history of recently issued commands is set to 20.

  2. The .login file.

    This is an executable command file that resides in the user's home directory. The .login also customizes the user's environment, but is only executed once, at login time. For this reason, you should use this file to set environment variables and to run shell script programs that need be done only once per login session. A sample .login is shown below:

    eval 'tset -s -Q'

    umask 022

    stty line 1 erase '^H' kill '^U' intr '^C' echoe

    setenv DISPLAY wheeler:0

    setenv SHELL csh

    setenv VISUAL /usr/bin/vi

    setenv EDITOR /usr/bin/emacs

    setenv ROOT /

    set path = (. ~/bin /usr/bsd /bin /usr/bin /usr/sbin \ /usr/bin/X11 /usr/demos /usr/local/bin)

    In this example, the user's terminal is further initialized with tset(1), then the file creation mask is set to 022. Some useful key bindings are set, using the command stty(1). The user's default display is set to be on the console screen of the machine called ''wheeler.'' Several important environment variables are set for commonly used utilities and the file system point of reference. Finally, the default path is expanded to include the user's own binary directory and other system directories.

For information on the shell programming commands used in these examples, see the csh(1) reference page.


Next | Prev | Up | Top | Contents | Index