Files
Startup and shutdown files
Commands are first read from /etc/zshenv; this cannot be overridden. Subsequent behavior is modified by the RCS and GLOBAL_RCS options. The RCS option affects all startup files while GLOBAL_RCS only affects global startup files (those shown here with a path starting with a /). If one of the options is unset at any point, any subsequent startup file of the corresponding type is not read. It is also possible for a file in $ZDOTDIR to re-enable GLOBAL_RCS. Both RCS and GLOBAL_RCS are set by default.
Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login shell, commands are read from /etc/zprofile and then $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read.
When a login shell exits, the files $ZDOTDIR/.zlogout and then /etc/zlogout are read. This happens with either an explicit exit via the exit or logout commands, or an implicit exit by reading end-of-file from the terminal. However, if the shell terminates due to exec'ing another process, the logout files are not read. These are also affected by the RCS and GLOBAL_RCS options. The RCS option affects the saving of history files. For example, if RCS is unset when the shell exits, no history file is saved.
If ZDOTDIR is unset, HOME is used instead. Files that were previously listed as being in /etc might be in another directory, depending on the installation.
'if [[ -o rcs ]]; then ...' so that it is not executed when zsh
is invoked with the '-f' option. List of files
- $ZDOTDIR/.zshenv
- $ZDOTDIR/.zprofile
- $ZDOTDIR/.zshrc
- $ZDOTDIR/.zlogin
- $ZDOTDIR/.zlogout
- ${TMPPREFIX}* (default is /tmp/zsh*)
- /etc/zshenv
- /etc/zprofile
- /etc/zshrc
- /etc/zlogin
- /etc/zlogout (installation-specific - /etc is the default)
Any of these files can be precompiled with the zcompile built-in command. If a compiled file exists (named for the original file plus the .zwc extension) and it is newer than the original file, the compiled file is used instead.