====== Startup Files ======
This question comes up quite often: \\
**"What do all those config files do? When are they run?"**
Okay, it's described in the [[http://zsh.dotsrc.org/Doc/Release/zsh_4.html#SEC17|manpage (/STARTUP FILES)]] and in the [[http://zsh.dotsrc.org/FAQ/zshfaq03.html#l19|FAQ (q.3.2)]], but I guess, I'll quickly put a page in the wiki, as well, just to make sure people can find the information.
====Where are my config files located?====
Good question. Usually, zsh's global config files are located in ''/etc'' (eg. /etc/zshrc) and your personal configs are located in your home directory (eg. /home/ft/.zshrc).
**BUT** zsh is very flexible, so the location of the global config files (via compile time options), as well as the personal config files (via ''$ZDOTDIR''), may be changed.
Checking ''$ZDOTDIR'' is easy (and left as an exercise for the reader). Note, if ''$ZDOTDIR'' isn't set, ''$HOME'' is the location for per-user-config files. \\
Checking for the global location takes a little trick:
zsh% strings =zsh | grep zshrc
/etc/zsh/zshrc
.zshrc
See? That's the output on a [[http://www.debian.org/|debian]] System, where the global configs are put in ''/etc/zsh/''.
==== When are they read? ====
There are several types of config files for zsh. For each type there are two files: one global and one per-user file. The global file is read before the per-user one.
If you do not know what an interactive shell or a login shell is, **please** read [[http://zsh.dotsrc.org/Guide/zshguide02.html#l6|chapter 2 of the users guide]] (at least 2.1). I know people are impatient, so a here's quick way of testing, if you are in a login shell:
if [[ -o login ]] ; then
echo login shell
else
echo _no_ login shell
fi
Yes, you can test for interactive shells in the same way (but isn't that rather obvious?).
Here's a quick listing (first name is the global config file; the 2nd [the one with the dot] is corresponding the per-user config file). Note, that this listing is in chronological order.
''zshenv'' / / ''.zshenv''
* zshenv is the 1st file zsh reads; it's read for **every** shell, even if started with **-f** (setopt NO_RCS)
* .zshenv is the same, execpt that it's **not** read if zsh is started with **-f**
''zprofile'' / / ''.zprofile''
* read after zshenv, if the shell is a **login shell**
''zshrc'' / / ''.zshrc''
* read after zprofile, if the shell is an **interactive shell**
''zlogin'' / / ''.zlogin''
* read after zshrc, if the shell is a **login shell**
* note, that by zprofile and zlogin, you are able to run commands for login shells **before** and **after** zshrc
==== Shutdown Files ====
These are similar to Startup Files, so I'll add them here. \\
Shutdown Files are run, when a **login shell** exits. The available files are: ''.zlogout'' and ''zlogout'' (Note, that for Shutdown files, the **order is different** to Startup files: first the per-user file is read, then the global one).