MacOS – How to set “default” .bash_profile when opening Terminal on Catalina

bashmacosterminalzsh

I'm running Catalina, 10.15.2, which uses the new zsh shell as a default. I've created my own .bash_profile file in my home directory and I'm able to initialize this .bash_profile by typing:

source .bash_profile

The problem is that I have to keep typing "source …" each time I open a new terminal shell. How do I default the shell to always use this .bash_profile file? Thanks!

Best Answer

zsh uses different config files, see the 'STARTUP/SHUTDOWN FILES' section in man zsh. You can run one of

mv ~/.bash_profile ~/.zprofile
mv ~/.bash_profile ~/.zshrc

to rename the file, see the man page or https://support.apple.com/en-us/HT208050 for the difference between these:

If you're using a bash profile, such as to set environment variables, aliases, or path variables, you should switch to using a zsh equivalent. For example:

  • .zprofile is equivalent to .bash_profile and runs at login, including over SSH
  • .zshrc is equivalent to .bashrc and runs for each new Terminal session