How to load ~/.bash_profile when entering bash from within zsh?

Open ~/.zshrc, and at the very bottom of the file, add the following:

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

Every time you open the terminal, it will load whatever is defined in ~/.bash_profile (if the file exist). With that, you can keep your custom settings for zsh (colors, and etc). And you get to keep your custom shell settings in .bash_profile file.

This is much cleaner than using bash -l IMO.

If you prefer putting your settings in .bashrc, or .bash_login, or .profile , you can do the same for them.


Similarly, you could also move the common profile settings to separate file, i.e. .my_common_profile, and add the following to both .bash_profile and .zshrc:

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)