Star tup and Shutdown Files
The shell reads one or more files from your home directory when it starts up, and possibly one file when it terminates. The files are described in the following table. No error occurs if any given file does not exist.
File | Description |
---|---|
Ë/.cshrc | Read at startup |
Ë/.tcshrc | Read instead of Ë/.cshrc if it exists (tcsh onlyâif you're using tcsh, read references to Ë/.cshrc as "Ë/.tcshrc if it exists, Ë/.cshrc otherwise.") |
Ë/.login | Read by login shells at startup |
Ë/.history | Read by login shells at startup to initialize the history list |
Ë/.cshdirs | Read by login shells at startup to initialize the directory stack (tcsh only) |
Ë/.logout | Read by login shells at termination |
At startup, a login shell reads, in order, Ë/.cshrc, Ë/.history, Ë/.login, and (for tcsh only) Ë/.cshdirs. A non-login shell reads only Ë/.cshrc at startup.
At termination, a login shell reads Ë/.logout and writes Ë/.history and (for tcsh only) Ë/.cshdirs if the appropriate variables are set. (Ë/.history is saved if savehist is set. In tcsh, Ë/.cshdirs is saved if savedirs is set.) A non-login shell simply exits.
To execute commands in Ë/.cshrc that will only apply to interactive shells, place them inside the following construct:
if ($?prompt) then
commands
endif
To execute commands only for tcsh, place them inside this construct:
if ($?tcsh) then
commands
endif
Get Using csh & tcsh now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.