Bash – Why is Cygwin not sourcing the .bashrc

bashcygwin;

I'm switching to Cygwin from the bash shell that ships with Git for Windows, and for some strange reason the .bashrc file is not being sourced when I open a new Terminal. I have to

source .bashrc

manually just to get my normal settings. echo $0 $- returns -bash himBH

What could be the problem?

Best Answer

The minus at the start of $0 means that bash is being started as a login shell.

In this case, bash reads initialization commands from .bash_profile, not .bashrc.

The simplest fix is to create ~/.bash_profile if it doesn't already exist, and put

if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi

at the top.

See also: What's the conf file reading between login and non-login shell?