Mac – Terminal: run source ~/.bash_profile every time start new terminal

bashmacterminal

I installed some command line programs (e.g. rbenv), but every time I open a new Terminal tab, it looks like the environment gets reset. I need to source my .bash_profile manually:

source ~/.bash_profile

I followed some tutorials and put this code in my .bash_profile, but it doesn't work:

if [ -n "$BASH_VERSION" ] && [ -f $HOME/.bashrc ];then
    source $HOME/.bashrc
fi

This doesn't happen on my old Mac, and I don't know how to configure this.

Best Answer

If you are using oh-my-zsh, the default one that will be loaded automatically is ~/.zshrc. All you need to do is adding the following at the end of ~/.zshrc:

if [ -f ~/.bash_profile ]; then
  . ~/.bash_profile
fi