Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Need this output: echo $0 $- – Mikel Aug 3 '12 at 17:21
@Mikel: added to question; thanks. – iconoclast Aug 3 '12 at 17:26

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

at the top.

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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