VSCode集成终端创建了一个独立的窗口

20

我刚刚安装了VSCode和git bash。

我已经在settings.json文件中添加了以下行:

{
    "terminal.integrated.shell.windows": "D:\\Program Files\\Git\\git-bash.exe" 
}

当我按下Ctr+`打开集成的shell窗口时,它不是在主编辑器底部打开,而是打开一个新窗口。

Git Bash Winow

为什么通常的位置没有显示?
7个回答

19
根据此vscoode GitHub Issue (#7286)

...git-bash.exe是一个Windows应用程序(入口为WinMain),而bash.exe是一个控制台应用程序(入口为main)。要将其用作集成式shell,可执行文件必须是控制台应用程序,以便可以重定向stdin/stdout/stderr。

建议的方法是使用:

"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"

6

我的解决方案:

  1. 打开设置

  2. 停用:Windows Enable Conpty

Windows Enable Conpty


谢谢,这对我非常有效,其他所有答案都不起作用。 - Hassan ALAMI
经过数小时的故障排除,这对我起作用了。 - Fike Rehman
@HassanALAMI 我找不到“Windows Enable Conpty”。我该怎么找到它? - Shivam Gupta
2
@ShivamGupta Ctrl + Shift + P > "首选项:打开用户设置" > 搜索 "Windows Conpty" - Hassan ALAMI

2

实际上,我正在寻找解决这个确切问题的方法。@JBD说得很正确,但我想补充一点,即git-bash.exe文件被保留在git的正常程序文件夹中。

{
    "terminal.integrated.shell.windows": "D:\\Program Files\\Git\\git-bash.exe" 
}

但是,在vs Code的设置中需要链接的是另一个文件,它将使git bash在vs code终端中运行。该文件的路径位于“Git”文件夹内的“bin”文件夹中。

{
"terminal.integrated.shell.windows": "D:\\Program Files\\Git\\bin\\bash.exe" 
}

这将允许你在VS Code的终端窗口中运行git bash。

2

我遇到了同样的问题,但是接受的答案在最新版本的VSCode上已经不再适用(我正在使用1.74.3)。它会抛出类似下面的错误。

这已经过时了,配置默认shell的新推荐方式是通过创建终端配置文件在 #terminal.integrated.profiles.windows# 并将其配置文件名称设置为默认值在 #terminal.integrated.defaultProfile.windows#。目前这将优先于新的配置文件设置,但这将来会改变。

问题是,在Git中有两种类型的bash应用程序:

  1. git-bash.exe(在单独的窗口中打开)
  2. bash.exe(在VSCode终端窗口中打开)

bash.exe位于/bin文件夹内。

它需要在settings.json中进行以下配置

 "terminal.integrated.profiles.windows": {
    "Bash": {
      "path": "C:\\Program Files\\Git-2.35.1.2\\bin\\bash.exe"
    }
 }

1
谢谢,这应该是经过验证的答案! - undefined

1

我也遇到了这个问题,但我解决了它。

更改 Git Bash 的路径:

"terminal.integrated.shell.windows": "D:\Program Files\Git\bin\bash.exe"

并在 cmd 中取消勾选旧版控制台复选框 cmd 图片


1

对于那些使用通过Scoop安装的Git的用户,只需使用Scoop的安装文件夹路径:

"terminal.integrated.shell.windows": "${env:USERPROFILE}\\scoop\\apps\\git\\current\\bin\\bash.exe",

0

不确定所有情况,但在我的情况下,Git Bash的位置已更改为appdata而不是编程文件,因此您可以使用与所述相同的方法:

"terminal.integrated.shell.windows": "C:\\Users\\{user_name}\\AppData\\Local\\Programs\\Git\\bin\\bash.exe",

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接