I'm trying to automate my work environment set up using a batch file. I'm stuck at a point where I am not able to start the MingW64 Console from command line.
start "" "%ProgramFiles%\Git\bin\sh.exe" --login
works fine but it seems to open a different shell window than that I am looking for. I'll explain this with pictures.
What it opens is a default cmd style window with bash integrated. This window isn't even resizeable
What I want is
I was trying to use the command start "" "%ProgramFiles%\Git\git-bash.exe" --login -i -c /bin/bash
but it seems to quickly close the shell after opening it. If I execute the same file from explorer, the shell doesn't close automatically.
Here is my full batch file for reference
@echo on
REM start PHP and MYSQL
start "" mysql_server\UniServerZ\UniController.exe start_both
REM Open PhpMyAdmin
start "" http://localhost/us_opt1/
REM Open Folders
start "" %SystemRoot%\explorer.exe "E:\work\"
REM Open Git Bash Instance
:: in order to open the shell in that path
cd E:\work\
:: start "" "%ProgramFiles%\Git\bin\sh.exe" --login
start "" "%ProgramFiles%\Git\git-bash.exe" --login -i -c /bin/bash
REM start sublime text
start "" "E:\Sublime Text Build 3083 x64\sublime_text.exe"
Git Bash comes included as part of the Git For Windows package. Download and install Git For Windows like other Windows applications. Once downloaded find the included .exe file and open to execute Git Bash.
Run Command Prompt as Administrator and type choco install git and you'll be able to install git devoted to the command line.
For Windows 10, a quick access is to enter "Edit the system environment variables" in the Start Search of Windows and click the button "Environment Variables". Change the PATH variable (double-click on it or Select and Edit), and add the path where your MinGW-w64 has been installed to e.g., C:\mingw\mingw64\bin.
git-bash.exe -i -c "/bin/bash"
seems to work better.
This issue illustrates various other ways to call git-bash.exe
, but concludes:
Preferred way to run git-for-windows is using
git-cmd.exe
:
c:\git\git-cmd.exe --command=usr/bin/bash.exe -l -i
That however only opens a session in the current cmd, while git-bash.exe
opens a new windows.
Combined with this question (to open a new console) and this one (to avoid two CMD windows), I would use:
start /b cmd /c git-bash.exe -i -l -c "/bin/bash"
The OP Atif Mohammed Ameenuddin reports in the comments this as working fine:
start "" "%ProgramFiles%\Git\git-bash.exe"
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