7

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?

  • 1
    Need this output: echo $0 $- – Mikel Aug 3 '12 at 17:21
7

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.