如何从Windows上的命令行启动MingW控制台(GitBash)? [英] How to start MingW Console (GitBash) from Command Line on Windows?
问题描述
我正在尝试使用批处理文件自动设置我的工作环境。
开始%%ProgramFiles%\\在我的命令行中无法启动MingW64控制台。 \\ Git\bin \sh.exe--login
工作正常,但似乎打开一个不同的shell窗口比我正在寻找。我将用图片解释这一点。
它打开的是一个默认的cmd风格窗口与bash集成。此窗口甚至无法调整大小
我想要的是
说明了调用 git-bash.exe
的各种其他方法,但总结为:
运行git-for-windows的首选方法是使用
git-cmd.exe
:
c:\git\git-cmd.exe --command = usr / bin / bash.exe -l -i
但是只打开当前cmd中的会话,而 git-bash.exe
打开一个新窗口。
结合此问题< a>(打开新控制台)和这一个(以避免两个CMD窗口),我将使用:
start / b cmd / c git-bash.exe -i -l -c/ bin / bash
OP Atif Mohammed Ameenuddin 报告 in the comments this as working fine:
开始%ProgramFiles%\Git\ git-bash.exe
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.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"
这篇关于如何从Windows上的命令行启动MingW控制台(GitBash)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!