Customizing your shell environment: The .tcshrc file

So far, we have discussed customization that is set up inside your .login file. However, the shell reads this file only when you log into the shell or when you enter the tcsh command with the –l option. Note that the option is a lowercase "L".

To always have a customized shell session, you need to have a special shell script that customizes your shell variables each time you start the shell; this is the purpose of the .tcshrc file (also known as a startup script).

For example, you might put all your alias definitions and other setup instructions into this file. You want these instructions run when your shell starts after you login and whenever you explicitly create the shell during a session (for example, as a child shell to run a shell script).

Following is a sample .tcshrc file:

Figure 1. A sample .tcsh file
# ==================================================================
#                       path shell variable
#                       -------------------
# Lists directories in which to look for executable commands.
# ==================================================================
#set path = ( /bin /usr/local/bin /usr/bin )

# test if we are an interactive shell
if ($?prompt) then
# ==================================================================
#                       prompt shell variable
#                       ---------------------
# The string which is printed before reading each command from the
# terminal.  Currently set to display hostname, and current working
# directory.
# ==================================================================
set prompt = "%m:%~> "

# ==================================================================
#                       rmstar shell variable
#                       ---------------------
# If set, the user is prompted before 'rm *' is executed.
# ==================================================================
set rmstar

# ==================================================================
#                       noclobber shell variable
#                       ------------------------
# If set, output redirection will not overwrite existing files.
# ==================================================================
#set noclobber

# ==================================================================
# source complete.tcsh
# ==================================================================
if (`filetest -e /etc/complete.tcsh`) then
        source /etc/complete.tcsh
endif
endif  # interactive shell

# ==================================================================
# set up useful aliases
# ==================================================================
alias m more