Why do I need to source bash_profile every time Why do I need to source bash_profile every time bash bash

Why do I need to source bash_profile every time


Now that we've narrowed down the problem:

  1. Run ps -p $$ at the command line to determine that you are, in fact, using a bash shell.
  2. Realize that you are in zsh, which means you should be editing your profile in .zshrc.
  3. Copy the offending lines from .bash_profile to .zsh, OR
  4. Modify your .zshrc to directly source your .bash_profile.

UPDATE: Do what @TC1 mentions in the comments and keep the shell-specific code in each shell's own profile, and from those profiles, only source shell-agnostic code.


On Mac Catalina, I just had to open "preferences" on terminal and change the "shells open with" from "default" to "Command(complete path)", which the default path was "/bin/zsh". touch ~/.zshrc, if that file doesn't exist already, and copy/paste your stuff from ".bash_profile" into the ".zshrc" file.


bash_profile.sh is applicable for bash shell.if your default shell is not bash and if your default shell is someother shell for example zsh then you have to manually load the .bash_profile using source ~/.bash_profile.

You can always change the default shell to bash shell so that the .bash_profile file will be automatically loaded.

Inorder to automatically load .bash_profile, you can update your default shell to bash using the command chsh -s /bin/bash

cat /etc/shells will list the default shells available in themachine

enter image description here

echo $SHELL will display the currently active shell in your machine

enter image description here

To change active shell to a different shell, use chsh -s /bin/bash.Then echo $SHELL to verify if the shell has changed.