GitBash 未在 Visual Studio Code 中显示为终端选项 [英] GitBash not showing up as a terminal option in Visual Studio Code

查看:134
本文介绍了GitBash 未在 Visual Studio Code 中显示为终端选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 GitBash 作为一个选项插入到 Visual Studio Code 中.我的设置如下所示:

I am trying to insert GitBash as an option in Visual Studio Code. My settings look like so:

"terminal.integrated.profiles.windows": {
    "PowerShell": {
      "source": "PowerShell",
      "icon": "terminal-powershell"
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [],
      "icon": "terminal-cmd"
    },
    "GitBash": {
      "source": "GitBash",
      "path": ["F:\\Code\\Git\\bin\\bash.exe"],
      "icon": "terminal-bash"
    }
  },
  "terminal.integrated.defaultProfile.windows": "GitBash"

然而,在最后一行,Visual Studio Code 给出的错误是:

However, at the last line, the error that Visual Studio Code gave is:

Value is not accepted. Valid values: "PowerShell", "Command Prompt".(1)
The default profile used on Windows. This setting will currently be ignored if either #terminal.integrated.shell.windows# or #terminal.integrated.shellArgs.windows# are set.

我不明白我哪里出错了.

I do not understand where I went wrong.

注意:terminal.integrated.shell.windows" 自 2021 年 4 月起已弃用.

Note: "terminal.integrated.shell.windows" is deprecated as of April 2021.

推荐答案

我相信 Visual Studio Code 使用您的 PATH 变量来查找您的机器上可用的配置文件.我猜你没有在你的 PATH 中设置 Git Bash 的位置.但是,这应该没问题,因为您在设置中指定了 path 属性.问题是您还设置了 source 属性.根据terminal.integrated.profiles.windows设置的描述,您可以设置source path,而不是两者:

I believe Visual Studio Code uses your PATH variables to find which profiles are available on your machine. I am guessing you do not have the location of Git Bash set in your PATH. But, that should be fine since you specify the path property in the setting. The issue is you are also setting the source property. According to the description for the terminal.integrated.profiles.windows setting, you can either set the source or the path, not both:

通过终端下拉菜单创建新终端时要显示的 Windows 配置文件.设置为 null 以排除它们,使用 source 属性使用默认检测到的配置.或者,设置path和可选的args

The Windows profiles to present when creating a new terminal via the terminal dropdown. Set to null to exclude them, use the source property to use the default detected configuration. Or, set the path and optional args

删除 source 属性,看看问题是否解决,您可以在 Visual Studio Code 中打开一个 git bash 终端.

Delete the source property, and see if the issue resolves and you can open a git bash terminal in Visual Studio Code.

此外,您可能需要在进行这些更改后重新启动 Visual Studio Code.这可能是一个单独的错误,但 terminal.integrated.profiles.windows 设置在您重新启动之前不会检测到任何添加的新配置文件.

Also, you may need to restart Visual Studio Code after making these changes. It might be a separate bug, but the terminal.integrated.profiles.windows setting won't detect any new profiles added until you restart.

这篇关于GitBash 未在 Visual Studio Code 中显示为终端选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆