at⋅a⋅rax⋅is

Shell startup files

Bash startup files

flowchart TD bash([bash]) bash --> lq{"Login?"} lq -->|yes| l1["/etc/profile"] l1 --> lfo subgraph lfo ["— first of —"] direction TB lbp["~/.bash_profile"]--> |or| lbl["~/.bash_login"]--> |or| lhp["~/.profile"] end lfo -->|on logout| lo1["~/.bash_logout"] --> lo2["/etc/bash.bash_logout ¹"] lq -->|no| iq{"Interactive?"} iq -->|yes| ni1["/etc/bash.bashrc ¹"] --> ni2["~/.bashrc"] iq -->|no| nn1["$BASH_ENV"]

¹ Debian/Ubuntu-specific. Bash does not natively source these files; they are provided by the distribution.

ZSH startup files

ZSH has an incredibly useful command,

zsh -l -o sourcetrace
flowchart TD zsh([zsh]) zsh --> e1["/etc/zshenv ²"] --> e2["~/.zshenv"] e2 --> lq{"Login?"} lq -->|yes| lp1["/etc/zprofile ²"] --> lp2["~/.zprofile"] lp2 --> iq{"Interactive?"} iq -->|yes| ls1["/etc/zshrc ²"] --> ls2["~/.zshrc"] --> ll1["/etc/zlogin ²"] iq -->|no| ll1 ll1 --> ll2["~/.zlogin"] ll2 -->|on logout| lo1["~/.zlogout"] --> lo2["/etc/zlogout ²"] lq -->|no| iq2{"Interactive?"} iq2 -->|yes| ni1["/etc/zshrc ²"] --> ni2["~/.zshrc"] iq2 -->|no| stop((" "))

² On Linux (Debian/Ubuntu) the system files live under /etc/zsh/ (e.g. /etc/zsh/zshenv). On macOS they are at the top level of /etc/ (e.g. /etc/zshenv). Zsh does not source /etc/profile — any distro that does so is driving it from within /etc/zprofile.

source