Issue
I've used bash for two years, and just tried to switch to zsh shell on my OS X via homebrew. And I set my default (login) shell to zsh, and I confirmed it's set properly by seeing that when I launch my Terminal, it's zsh shell that is used in default.
However, when I try to enter bash shell from within zsh, it looks like not loading ~/.bash_profile
, since I cannot run my command using aliases, which is defined in my ~/.bash_profile
like alias julia="~/juila/julia"
, etc.. Also, the prompt is not what I set in the file and instead return bash-3.2$
.
For some reasons, when I set my login shell to bash, and enter zsh from within bash, then ~/.zshrc
is loaded properly.
So why is it not loaded whenever I run bash
from within zsh? My ~/.bash_profile
is symbolic linked to ~/Dropbox/.bash_profile
in order to sync it with my other computers. Maybe does it cause the issue?
Solution
An interactive bash
reads your ~/.bash_profile
if it's a login shell, or your ~/.bashrc
if it's not a login shell.
A typical .bash_profile
will contain something like:
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
so .bashrc
can contain commands to be executed by either login or non-login shells.
If you run bash -l
rather than just bash
, it should read your .bash_profile
.
Reference: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
Answered By - Keith Thompson