Skip to content

Instantly share code, notes, and snippets.

Using zsh on mac

The zsh shell is not only very powerful, but can also be confusing, expecially when it comes to choosing between .zprofile, .zshenv, .zshrc files to configure the $PATH. As there are divergent opinions on Stack Overflow and web blogs, hopefully this gist can help to provide more clarification.

The most detailed background explanation I found is the gist by Linerre. While I really recommand to read it, the key aspect is that the configuration files are processed in the order .zshenv, .zprofile and .zshrc, as on macOS a zsh shell is always treaded as a login shell. MacOS further changes the $PATH after the processing of .zshenv with the path_helper, which could lead to unexpected behaviour when following the the zsh documentation which suggests to configure the $PATH in .zshenv. Therfore, I am configuring zsh in the following way:

Important zsh co