首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >GitBash在Visual代码中没有显示为终端选项

GitBash在Visual代码中没有显示为终端选项
EN

Stack Overflow用户
提问于 2021-06-21 12:57:38
回答 15查看 23.1K关注 0票数 16

我试图在Visual代码中插入GitBash作为选项。我的设置看起来是这样的:

代码语言:javascript
运行
复制
"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代码给出的错误是:

代码语言:javascript
运行
复制
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.

我不明白我哪里出了问题。

注:"terminal.integrated.shell.windows"于2021年4月被取消。

EN

回答 15

Stack Overflow用户

回答已采纳

发布于 2021-06-21 13:26:58

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

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

删除source属性,查看问题是否得到解决,您可以在Visual代码中打开一个git终端。

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

票数 24
EN

Stack Overflow用户

发布于 2021-06-26 08:32:48

与代码版本1.57.1。

在env中添加了Git、Git\bin、Git\cmd的路径。有"Git Bash“配置文件的源和路径元素。移除源并只保留路径。当将defaultProfile添加为"Git“时,得到的"Value不被接受”错误。重新启动VS代码没有帮助。

将"Git Bash“改为"GitBash”(删除的空间)对我来说终于奏效了:

代码语言:javascript
运行
复制
"terminal.integrated.profiles.windows": {
    "GitBash": {
      "path": ["D:\\ProgramFiles\\Git\\bin\\bash.exe"],
      "args": []
    },
    ...
}
"terminal.integrated.defaultProfile.windows": "GitBash"

我不知道空间是否真的是问题所在。因为有一个配置文件“命令提示符”,它的名字和识别空间!为了进一步证实这一点,将"PowerShell“改为”PowerShell“,它也起了作用。

我不清楚空间是如何重要的,只有在"GitBash“简介中。

票数 32
EN

Stack Overflow用户

发布于 2021-09-28 20:10:41

对于在git安装中使用自定义dir的任何人:它不适用于版本: 1.60.2 (用户设置)

Win10用户:

  1. 安装或复制C:\Program中的git
  2. 添加路径变量名称: GIT_HOME_2变量: C:\Program \Git
  3. 双击路径并添加"%GIT_HOME_2%\bin“
  4. 打开VS代码,您将看到bash终端
代码语言:javascript
运行
复制
{
    "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"
        },
       
    },
    "terminal.integrated.env.windows": {
    
    },
    "terminal.integrated.defaultProfile.windows": "Git Bash"
}
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68068359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档