Why Is ~/.bash_profile Not Automatically Sourced in a macOS zsh Shell?

Since macOS switched to zsh shell as a default from bash, you now need to use a .zprofile file instead of .bash_profile. This is because in a zsh shell, ".zprofile" is the startup file equivalent of bash's ".bash_profile". Therefore, all you need to do is simply copy over the contents of your .bash_profile file to .zprofile. This is can be done, for example, in the following way:

cp ~/.bash_profile ~/.zprofile

Now whenever you start a new terminal session, your .zprofile file should be automatically sourced.


This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.