3 ms·
I set $PATH in ~/.zshenv. If you don't, you can't use any of your "extra stuff" in your zsh-scripts, as they do not use login or interactive sessions. And then
by sidneythekidney 3y ago
I set $PATH in ~/.zshenv. If you don't, you can't use any of your "extra stuff" in your zsh-scripts, as they do not use login or interactive sessions. And then I unset GLOBAL_RCS so the system configfiles don't override my settings.
In your guide, under ~/.zshenv, you mention that "macOS overrides this for PATH settings for interactive shells", without mentioning why or how. What's happening is that macOS sets your path in /etc/zprofile.
It seems your guide is missing a few global configfiles :) This is the order for an interactive login shell [1]:
/etc/zshenv
${ZDOTDIR:-$HOME}/.zshenv
/etc/zprofile (login)
${ZDOTDIR:-$HOME}/.zprofile (login)
/etc/zshrc (interactive)
${ZDOTDIR:-$HOME}/.zshrc (interactive)
/etc/zlogin (login)
${ZDOTDIR:-$HOME}/.zlogin (login)
/etc/zlogout (login - loaded on logout)
${ZDOTDIR:-$HOME}/.zlogout (login - loaded on logout)
In fact, the configfiles you mention are only loaded the way you've mentioned them, if the option GLOBAL_RCS is unset. And if GLOBAL_RCS is unset, macOS does not override your PATH, because/etc/zprofile is not loaded :)
1: <https://zsh.sourceforge.io/Doc/Release/Files.html https://zsh.sourceforge.io/Doc/Release/Files.html>
- DanielKehoe 3y agoThank you! That's informative.
- sidneythekidney 3y agoOops, I just remembered this, and I got the order of the last two files wrong. ${ZDOTDIR:-$HOME}/.zlogout is loaded before /etc/zlogout when logging out of a login session :)