Customizing the tcsh Shell

You can customize tcsh by changing certain environment variables, by creating aliases for frequently used commands, or by binding keys to commands (see “bindkey” in Section 1.5.4, later in this chapter).

If you want to make your customizations permanent (so you don’t have to issue the commands each time you log in), put the appropriate commands in one of tcsh’s startup files in your home directory. Here are some of the startup files into which you can put these commands:

.tcshrc

This script is executed each time you launch a shell. When you open a Terminal window, .tcshrc is executed. If you start a sub-shell (or run a csh shell script), .tcshrc will again be executed. If your .tcshrc contains recursive definitions, consider moving those commands to .login. For example, if you issue the command set path = ( $HOME/bin $path ) in your .tcshrc, then $HOME/bin will get prepended to your PATH environment variable each time you launch a sub-shell.

.login

This script is executed each time you launch a login shell, which includes opening a new Terminal window or logging in remotely. The .login script runs after .tcshrc. The .login file should contain settings that should only be applied once, such as PATH settings. The .login script is guaranteed to be run only once, regardless of how many sub-shells you invoke under a single login shell.

.logout

This script is run when you exit a login shell, but not when you exit a sub-shell.

The following listing shows ...

Get Mac OS X for Unix Geeks 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.