I need to start the git-bash (sh.exe) with a predefined path in a Windows environment.
For cmd.exe this can be done with a command like:
cmd.exe /K "cd /d {PATH_GOES_HERE}"
For powershell.exe this can be done with this command:
powershell.exe -noexit -command "cd '{PATH_GOES_HERE}'"
But I could not manage to get that same with git-bash aka sh.exe. I tried stuff like …
sh.exe --login -i -c "cd {PATH_GOES_HERE}"
… but I could not make it work.
The command line itself works, by entering …
sh.exe --login -i -c "ls"
… I get the bash-colorized output of the directory
Best Answer
Thanks to a tip from Michael D, I installed Git with the feature "Git Bash Here". Then I looked up the way Git does it by browsing the registry at:
That gave me the command to use:
Where
%1
stands for the path provided by the Windows Explorer.So all I had to do was to go for a command like:
Btw, no need to transform Windows paths to stuff like
/c/users/myuser/...
That means I am not using sh.exe but git-bash.exe from now on.
Thanks mates.