Domanda

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

È stato utile?

Soluzione

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.

Altri suggerimenti

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

"C:\Program Files (x86)\Git\bin\sh.exe" --login -i
cd "%cd%\Projects\current"
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top