【问题标题】:VSCode Integrated Terminal creates a separate windowVSCode 集成终端创建一个单独的窗口
【发布时间】:2018-05-08 12:49:01
【问题描述】:

刚刚安装了 VSCode 和 git bash。

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

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

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

为什么不显示在通常的地方?

【问题讨论】:

    标签: bash visual-studio-code


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        【解决方案3】:

        我的解决方案:

        1. 打开设置

        2. 停用:Windows Enable Conpty

        【讨论】:

        • 谢谢,这对我来说非常有效,所有其他答案都不起作用
        • 经过数小时的故障排除后,这对我有用
        • @HassanALAMI 我找不到“Windows Enable Conpty”。我怎样才能找到它?
        • @ShivamGupta Ctrl + Shift + P > “首选项:打开用户设置” > 搜索“Windows Conpty”
        【解决方案4】:

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

        更改 git bash 的路径

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

        在 cmd 中取消选中旧版控制台复选框 Image of cmd

        【讨论】:

          【解决方案5】:

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

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

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

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

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

          【讨论】:

            【解决方案6】:

            据此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"
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2023-03-23
              • 1970-01-01
              • 2020-04-27
              • 1970-01-01
              • 2021-04-30
              • 2011-01-16
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多