Organizing Your Startup Files
You need to choose which of the two startup files you want to put given commands in. When I suggest an addition to a startup file in this handbook, I indicate the preferred file to minimize confusion. If you're making your own additions, consider the issues below when deciding where a command belongs.
You may discover that a little rearrangement of your startup files is in order even if you've never altered them. The boilerplate startup files that vendors ship for use in creating new accounts often have commands in the wrong file. For instance, the history and prompt variables are sometimes set in .login, rather than in .cshrc.
Login Versus Non-Login Shells
The shell you get when you log in is (naturally) a login shell, and it reads both .cshrc and .login. There are also non-login shells, such as those that execute commands implemented as csh scripts, or those that execute !command shell escapes from programs like mail, more, or vi. Non-login shells read only .cshrc.
Consequently, if a command must be run for each shell that starts up, the command should usually appear in .cshrc. Commands that need to be run only at login should appear in .login. Examples of the latter include:
Commands that affect your terminal settings, like tset, reset, and stty.
Commands that set environment variables. (Non-login shells inherit environment variables from the login shell, so you need to set those variables only once, using .login, not .cshrc.)
Commands like biff, which ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access