0

I'm a lazy guy and I would like to have a bat file launch my whole environment (on Windows).

My problem is with git bash. I can successfully launch a git bash shell, my problem is to automaticaly execute a cd command right after it opens.

So far I'm doing :

"C:\Program Files (x86)\Git\bin\sh.exe" --login -i

What I would like is to add :

"cd ~/Projects/current"

I've tried after some research:

"C:\Program Files (x86)\Git\bin\sh.exe" --login -i && "cd ~/Projects/current"

"C:\Program Files (x86)\Git\bin\sh.exe" --login -i "cd ~/Projects/current"

start cmd /k "C:\Program Files (x86)\Git\bin\sh.exe" --login -i && "cd ~/Projects/current"

With every try I end up in ~/Desktop. It seems that the cd is never executed

2 Answers 2

2

After sh.exe is launching, it will alway wait for your input, so the 2nd command will ever execute until the sh.exe exists.

To meet your proposal, you may add the "cd ~/Projects/current" in the "profile" , you can find it in $GIT_INSTALL_PATH\etc\profile, it acts something like autoexec.bat, which allow you to execute commands you want after sh.exe starts.

Sign up to request clarification or add additional context in comments.

4 Comments

Didn't know that file. I keep getting "No such file or directory" even when I specify the full path. Any idea why ? I placed the cmd at the end of the file.
Please check if you path is correct or not, it works fine in my git. ~ is mapped to the path /c/users/<username> in Windows 7.
My path looks good and I tried different ways. I'll get it to work. Is there a special place to add the cmd ?
i just appended the "cd ~/nova" at the end of profile, and it works fine in the git bash.
0

You have to use "\". Try like this :

"C:\Program Files (x86)\Git\bin\sh.exe" --login -i
cd "%cd%\Projects\current"

1 Comment

I tried, didn't solve. When using path in git bash it's unix style. That's why I am using /. Thanks for the try

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.