The list and order of startup files for zsh (Ch 2) are (ZDOTDIR
if not set defaults to HOME
):
/etc/zshenv
Always run for every zsh. (not present on my MBP)$ZDOTDIR/.zshenv
Usually run for every zsh (see below)./etc/zprofile
Run for login shells.$ZDOTDIR/.zprofile
Run for login shells./etc/zshrc
Run for interactive shells.$ZDOTDIR/.zshrc
Run for interactive shells./etc/zlogin
Run for login shells. (not present on my MBP)$ZDOTDIR/.zlogin
Run for login shells.
/etc/zshenv
does not exist on macOS.
$ZDOTDIR/.zshenv
is for user-defined env variables, it is run by every shell invocation.
I added sourcing of .zprofile
for non-interactive, non-login shells.
/etc/zprofile
on macOS executes
$ eval `/usr/libexec/path_helper -s`
that sets and exports the system-wide PATH
and MANPATH
The possible paths are:
-
${\mathbf{\color{red}RED \longrightarrow}}$ : login, interactive -
${\mathbf{\color{cyan}CYAN \longrightarrow}}$ : login, non-interactive -
${\mathbf{\color{green}GREEN \longrightarrow}}$ : non-login, interactive -
${\mathbf{\color{blue}BLUE \longrightarrow}}$ : non-login, non-interactive
The above diagram has been inspired by this blog post and its companion repo. The post describes an interesting setup for covering multiple shell types.
for now I keep a non version controlled file .secret_keys