.zshenv vs. .zshrc

Relevant excerpt from zshโ€™s manpage:

Commands are first read from /etc/zshenv [โ€ฆ] 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.

In a nutshell:

.zshenv

Use this for environment variables and settings needed by all processes (PATH, EDITOR, etc.)

[!NOTE] A lot of install tools get this wrong and will append to $PATH in .zshrc, which works fine for CLI usage, but might cause confusion when trying to run it from another process.

.zshrc

Use this for interactive shell customizations (aliases, functions, prompt, completions).

First published 2025-09-12
Last updated
Filed under
  • cli
  • zsh