Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use MinGW on windows 7. I have a .bashrc with some aliases in it. The file is in my home folder which is where MinGW starts me in, so it also believes that the folder is my home folder. It does not load the contents of the folder automatically. I have to run the bash command to get the aliases to work.

I have tried renaming it to .bash_profile. This only made things worse as it didn't load automatically and also didn't load when I ran bash manually.

How can I fix this problem?

share|improve this question
Sorry the path should have been: C:\MinGW\msys\1.0\home\Your_Username_Here\.profile – user125075 Mar 27 '12 at 18:15

4 Answers 4

up vote 26 down vote accepted

bash is probably getting started as a login shell, in which case it doesn't read .bashrc automatically. Instead, it reads .bash_profile. From the Bash manual:

So, typically, your `~/.bash_profile' contains the line

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

after (or before) any login-specific initializations.

So in summary, create a .bash_profile file in your homedir, and add the line quoted above.

If your bash is actually getting invoked as sh, then you'll need to use .profile instead of .bash_profile (see the "Invoked with name sh" section of the Bash manual link above).

share|improve this answer
Thanks for the idea, didn't work though. Like I said in the question, putting the alias commands in .bash_profile doesn't work at all, so it seems like that doesn't get read. – KurToMe Mar 27 '12 at 17:15
This gave me the idea to do exactly what you said except to put it in the .profile file instead. For some reason that worked (maybe MinGW doesn't use Bash by default or something crazy). If you add this option to your answer I'll mark it as accepted. – KurToMe Mar 27 '12 at 17:17
Ah, there was a typo in my question that I fixed, I was calling it .bash_rc in the question, but I meant .bash_profile. – KurToMe Mar 27 '12 at 17:41
somewhat more terse: [ -f ~/.bashrc ] && . ~/.bashrc – Rich Homolka Mar 27 '12 at 18:42
@KurToMe I edited to cover your situation. – jjlin Mar 27 '12 at 19:04

I am running Windows XP and had the same problem. I found HOWTO Create an MSYS Build Environment.

This is the important line:

To help identify the runtime build and the current working directory, the following can be added to the ~/.profile file.

In MinGW shell, I created .profile:

cd ~
touch .profile

I used Notepad++ to edit it as a Unix format text file named .profile and saved it in my home directory, C:\MinGW\msys\1.0\home\Your_Username_Here\.profile

Then I added my alias and saved:

alias n='nano -w'

Then I fired up the MinGW Shell shortcut from my start menu and hurray, it worked! nano with no text wrapping.

I hope this helps you.

share|improve this answer
What you're saying doesn't jive ... ~ means the users home directory ... then your stating c:\MinGW\msys\1.0\home ... that doesn't make any sense the tilde is a reference to the USERS home ... on windows that %userprofile% ... – Eddie B Oct 20 '12 at 5:09
@Bryan: +1 thanks, it works – legends2k Apr 22 '14 at 7:09

I did not find the .bash_profile to work for me (it wasn't being read), so I took the .profile approach and put within it:

exec bash

This replaces my current shell with a fresh start of bash, which read my .bashrc

I'm thinking that using a .profile suggests that sh is used at login, not bash.

share|improve this answer

For me for MINGW installed with GIT, worked: .bash_profile put in C:\Users\[user_name]

This is also the directory where ~ points to in shell (pwd).

Just like that :)

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.