3.5. What Goes in Shell Setup Files?
Setup files for login shells ( Section 3.4) -- such as
.profile -- typically do at least the
Set the search path
(Section 27.6) if the system default path
isn't what you want.
Set the terminal type
(Section 5.3) and make various
terminal settings (Section 5.7, Section 5.8) if the system might not know your terminal
(if you log in from various terminals over a dialup line or from a
terminal emulator on a desktop machine, for instance).
Set environment variables
(Section 35.3) that might
be needed by programs or scripts that you typically run.
Run one or more commands that you want
to run whenever you log in. For example, if your system
login program doesn't show the
message of the day, your setup file can. Many people also like to
print an amusing or instructive fortune. You also might want to run
who (Section 2.8)
or uptime (Section 26.4) or w (a combination of the
other two, but not found on all systems) for information about the
In the C shell, the .cshrc
file is used to establish settings that will apply to every instance
of the C shell, not just login shells. For example, you typically
want aliases (Section 28.2) available in every interactive shell you
run -- but these aren't passed through the
environment, so a setup file has to do the job. You may wish to put
all of your aliases into another file, such as
.aliases, or qualify the name with the
shell's name, such as
.csh.aliases, to allow for different alias
formats between shells, and then you can use the
source command to read in that file on startup
Even novices can write simple setup files. The trick is to make these
setup scripts really work for you. Here are some of the things you
might want to try:
Creating a custom prompt.
Coordinating custom setup files on different machines (Section 3.18).
Making different terminal settings depending on which terminal
you're using (Section 3.10
Seeing the message of the day only when it changes.
Doing all of the above without making your login take forever.
--TOR and SJC
Copyright © 2003 O'Reilly & Associates. All rights reserved.