I have a batch file that sets up my environment by opening a number of "git bash" shell windows. This works perfectly apart from one annoying feature where if you press Ctrl C (or send any other Term signal) the whole bash window will close.
I want the window to behave as if it has been opened normally and so when it receives a term signal it goes back to the bash prompt.
Here is the current contents of my setup.bat file:
C:
cd \project\
start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login -i -l -c "source ali.sh && mvn spring-boot:run"
cd \project2\
start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login
Note that the first start command runs maven and when i want to restart the command (press Ctrl+C) it closes the whole window. The second start command creates a new bash window in that directory which works like a normal bash window even with Ctrl+C, BUT I want it to have run a command at the start.
Is this possible? Many thanks for all your help
Something like this might work for you:
C:
cd \project\
start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login -i -l -c "sh -c 'source ali.sh && mvn spring-boot:run; exec sh'"
The trick is wrapping the command in:
sh -c '...; exec sh'
Where sh is your shell, might be bash.
You might actually to able to just suffix each command with: exec sh, eg:
start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login -i -l -c "source ali.sh && mvn spring-boot:run; exec sh"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With