4

I'm using ConEmu on Windows with Git for Windows installed. When I try to execute an .sh script, the software starts an instance of Windows' default console and executes the script there. How can I make ConEmu / Git for Windows execute the .sh script in the same window the command is initialized from?

ThePiachu
  • 8,695
  • 17
  • 65
  • 94

1 Answers1

4

So there are a few things one needs to do after a clean install of ConEmu and Git for Windows to make everything run seamlessly.

1) C:\Program Files\Git\bin needs to be added to PATH. Git for Windows only appears to add C:\Program Files\Git\cmdto PATH. This should allow you to run commands like sh test.sh ABC and they should work

2) To make things even easier and not have to type sh all the time, we need to tell Windows to associate .sh with sh, as well as pass parameters properly. We do this by typing:

assoc .sh=sh

ftype sh="C:\Program Files\Git\bin\sh.exe" "%1" %*

3) If parameters are still not passed, it might be a registry issue. To fix it, we press Win+r, type in regedit and run the Registry Editor. There might be a few places where the edit needs to be made, but one of them should be HKEY_CLASSES_ROOT\Applications\sh.exe\shell\open\command. We edit the entry to say

"C:\Program Files\Git\bin\sh.exe" "%1" %*

4) Bonus: To make .sh files execute without having to write ".sh" at the end, add .SH to PATHEXT in environmental variables.

That should allow us to run .sh files from ConEmu using Git for Windows without it opening in a separate window.

ThePiachu
  • 8,695
  • 17
  • 65
  • 94
  • One note. Adding `git/bin` or `git/usr/bin` may break .cmd scripts, if the directory contains such files as `find.exe`. So, it's preferable to modify `PATH` in the ConEmu task command. – Maximus Mar 27 '16 at 09:51