Luc*_*hel 8 terminal git-bash visual-studio-code
我试图在 Visual Studio Code 中插入 GitBash 作为一个选项。我的设置如下所示:
"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"
Run Code Online (Sandbox Code Playgroud)
但是,在最后一行,Visual Studio Code 给出的错误是:
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.
Run Code Online (Sandbox Code Playgroud)
我不明白我哪里出错了。
注意:"terminal.integrated.shell.windows"
自 2021 年 4 月起已弃用。
我相信 Visual Studio Code 使用您的 PATH 变量来查找您的机器上可用的配置文件。我猜你没有在你的 PATH 中设置 Git Bash 的位置。但是,这应该没问题,因为您path
在设置中指定了属性。问题是您也在设置该source
属性。根据该说明terminal.integrated.profiles.windows
的设置,您可以设置source
或对path
,而不是两个:
通过终端下拉菜单创建新终端时要显示的 Windows 配置文件。设置为 null 以排除它们,使用该
source
属性使用默认检测到的配置。或者,设置path
和可选args
删除该source
属性,看看问题是否解决,您可以在 Visual Studio Code 中打开一个 git bash 终端。
此外,您可能需要在进行这些更改后重新启动 Visual Studio Code。这可能是一个单独的错误,但在terminal.integrated.profiles.windows
您重新启动之前,该设置不会检测到任何添加的新配置文件。
当粘贴到 settings.json 中时,这对我有用:
{
"terminal.integrated.profiles.windows": {
"GitBash": {
"path": [
"C:\\Program Files (x86)\\Git\\bin\\bash.exe"
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
但前提是“GitBash”没有空格。“Git_Bash”也可以,但“Git Bash”不行。
如果您希望“GitBash”成为默认值,请使用以下语法:
{
"terminal.integrated.profiles.windows": {
"GitBash": {
"path": [
"C:\\Program Files (x86)\\Git\\bin\\bash.exe"
]
}
},
"terminal.integrated.defaultProfile.windows": "GitBash"
}
Run Code Online (Sandbox Code Playgroud)
VS 代码版本 1.57.1。
在 env 中添加 Git、Git\bin、Git\cmd 的路径。具有带有源和路径元素的“Git Bash”配置文件。删除了源并只保留了路径。将 defaultProfile 添加为“Git Bash”时出现“不接受值”错误。重新启动 VS Code 没有帮助。
将“Git Bash”更改为“GitBash”(删除了空格)终于对我有用了:
"terminal.integrated.profiles.windows": {
"GitBash": {
"path": ["D:\\ProgramFiles\\Git\\bin\\bash.exe"],
"args": []
},
...
}
"terminal.integrated.defaultProfile.windows": "GitBash"
Run Code Online (Sandbox Code Playgroud)
我不确定空间是否真的是问题所在。因为有一个配置文件“命令提示符”在其名称中带有空格并被识别!!!为了进一步确认这一点,将“PowerShell”更改为“Power Shell”,它也有效。
我不清楚空间仅在“GitBash”配置文件中的重要性。
小智 6
我有 VS 代码 1.63.2
移除source
财产或空间并"Git Bash"
没有帮助。但我在他们的官方网站上找到了这个,我注意到该.exe
文件本身是在以下位置指定的path
:
{
"terminal.integrated.profiles.windows": {
"My PowerShell": {
"path": "pwsh.exe",
"args": ["-noexit", "-file", "${env:APPDATA}PowerShellmy-init-script.ps1"]
}
},
"terminal.integrated.defaultProfile.windows": "My PowerShell"
}
Run Code Online (Sandbox Code Playgroud)
所以我尝试添加\\bash.exe
到设置中的路径并且它有效:
"terminal.integrated.profiles.windows": {
"GitBash": {
"path": "D:\\Git\\bin\\bash.exe",
"icon": "terminal-bash"
}
},
"terminal.integrated.defaultProfile.windows": "GitBash"
Run Code Online (Sandbox Code Playgroud)
小智 5
对于使用自定义目录进行 git 安装的任何人:它不适用于版本:1.60.2(用户设置)
Win10用户:
{
"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"
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1259 次 |
最近记录: |