Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've seen this but it doesn't work for me. I'm not using Git's version of bash but the one that comes with cygwin, so that could be part of the problem. Here is how I have my tab in Console2 set up:

Title: bash.exe
Shell: C:\cygwin\bin\bash.exe --login -i

This is my registry entry:

            Open Console2 Here
                "C:\Console2\Console.exe" -d "%1"

bash always starts in my home directory instead of the directory I'm clicking on, then I have to cd /cygdrive/d/code ... etc. I tried removing the value in the "Startup dir" field, changing it to %1, %1% with no luck.

I also tried this solution but it didn't work for me either:

Title: bash.exe
Shell: C:\cygwin\bin\bash.exe -l


            Open Console2 Here
                "C:\Console2\Console.exe" -d "%V"

The solutions above work for the versions of bash.exe and sh.exe that are included with Git, but not the versions that are included with cygwin for some reason. Still looking for a reason for this.


I selected an answer below, but I think the second solution above would have worked if I had created the .profile file in the right folder. I kept trying to create it in my normal home directory instead of the home directory used by cygwin, which is why it never executed the script. This led me to believe that the .profile file was unnecessary. The answer I selected (thanks Hugh!) clearly explains how each of the scripts (.bash_profile, .bash_login, .profile, and .bashrc) are used by bash which helped me figure out that I was putting them in the wrong place.

share|improve this question
Try ConEmu? superuser.com/q/454380/139371 –  Maximus Sep 7 '12 at 5:38
I'll look into ConEmu but I'm also going to put a bounty on this question. It just seems like there should be a way! –  Koveras Sep 12 '12 at 16:15

2 Answers 2

up vote 3 down vote accepted

From the manual,

When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists.

/etc/profile by default contains the following code:

# Make sure we start in home unless invoked by CHERE
if [ ! -z "${CHERE_INVOKING}" ]; then
  cd "${HOME}" || echo "WARNING: Failed attempt to cd into ${HOME}!"

So one solution would be to create a Windows batch file that sets the environment variable CHERE_INVOKING before starting bash. That is not very neat.


After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

These profile scripts by default execute your ~/.bashrc script if it exists. Putting cd - at the end of my .bashrc works for me (with the latest Console2 and Cygwin bash):

echo 'cd -' >> ~/.bashrc

BTW, I invoke Console2 (Console.exe) with no arguments - Windows Explorer ensures that it starts up in the directory that I right-clicked. I'm using XP but I doubt MS would change this behavior in later versions of Windows. I also leave the "startup dir" option blank for my Bash tab.

share|improve this answer

Seems, you have not create ~/.profile with the following:

cd -


share|improve this answer
Sorry, I should have specified WHICH answer on that page I followed. It was the one from @CharlesRoper, which didn't involve using a .profile file in the root directory. I tried the solution you're referring to from svnpenn as well but it didn't work either. –  Koveras Sep 12 '12 at 21:06
Does ls shows this file after bash startup? –  Maximus Sep 12 '12 at 21:40
Nope... actually I managed to get @svnpenn's solution working with the bash.exe and sh.exe that are included with Git but the .profile file does nothing. –  Koveras Sep 12 '12 at 21:55
Scratch that last comment. I was putting the .profile file in the wrong directory. See my edit above. –  Koveras Sep 17 '12 at 16:12

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.