tcsh Startup and Shutdown

Introduction

If you want to use some of the nicer features of tcsh, such as command aliases, shell variables, environment variables, etc., you will want those changes to be in effect every time you log in. You can put commands in files to have the shell set up your preferred shell environment without requiring you to manually (and tediously) type those commands every time you log in.

Startup

tcsh reads and executes resource configuration (rc) files in this order:

  1. tcsh starts off executing commands in /etc/csh.cshrc and /etc/csh.login first. Your sys-admin may have added some things there on your behalf (like setting up a reasonable path).
  2. If you have the file ~/.tcshrc in your home directory, commands in that file will be executed next.
  3. If you don't have ~/.tcshrc, then it will look for ~/.cshrc and execute commands in that file.
  4. Next, if a file named ~/.history is present, it is read:
    • Commands from ~/.history are entered in command history but not executed.
    • You can instruct tcsh to store the last commands you executed to the ~/.history file when you log off by setting the shell variable savehist.

Shutdown

  • When you log out, tcsh executes commands in the /etc/csh.logout and ~/.logout files.