How to add and run multiple command in gitbash on Windows

how do I run multiple synchronous commands in gitbash on windows.
when I try to start new windows terminal using this script

#!/bin/bash
start "" "C:\Program Files\Git\git-bash.exe" --cd="C:\Users\chat_\projects\backend" -c "poetry shell" + 
"&& uvicorn app:main:app --reload" $SHELL

I can’t start the second command after the poetry shell was already spawn
i got this error
bash: && uvicorn app:main:app --reload: command not found
what should I do ??

1 Like

Try && outside double quotes and maybe you need full path to uvicorn too:

start "" "C:\Program Files\Git\git-bash.exe" --cd="C:\Users\chat_\projects\backend" -c "poetry shell" && "uvicorn app:main:app --reload" $SHELL

That is how I do it in my Linux shell script wrapper:

/path/command1 && /path/command2 --arg1 --arg2 && /path/command3
1 Like

I have tried outside double quotes but it still same error, also got the same error with this script (it has the same path I installed uvicorn inside the poetry shell).
start "" "C:\Program Files\Git\git-bash.exe" --cd="C:\Users\chat_\projects\backend" -c "poetry shell" && --cd="C:\Users\chat_\projects\backend" "uvicorn app:main:app --reload" $SHELL
this command has spawn shell but uvicorn still not running.
bash: && uvicorn app:main:app --reload: command not found

Look like poetry shell is setting up new environment and it is not finding uvicorn in the path. Here is one more try

start "" "C:\Program Files\Git\git-bash.exe" --cd="C:\Users\chat_\projects\backend" -c "poetry shell && uvicorn app:main:app --reload" $SHELL
1 Like

I have tried this command but it was immediately closed(bash command not found & exit code) and did not run the command after I run the script, I want the shell to be still open.

when i add second path it show this error
bash: --cd=C:\Users\chat_\projects\backend: No such file or directory

I add poetry run before uvicorn and everything works fine. thank you for help

1 Like