首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从Visual代码集成终端在Windows上使用Bash?

如何从Visual代码集成终端在Windows上使用Bash?
EN

Stack Overflow用户
提问于 2017-03-05 09:51:20
回答 21查看 669.5K关注 0票数 460

Windows上的Visual代码默认使用PowerShell作为集成终端。如果要使用Visual代码中的Bash,应遵循哪些步骤?

EN

回答 21

Stack Overflow用户

发布于 2018-06-03 12:26:23

对我来说,这是唯一有效的组合!

代码语言:javascript
运行
复制
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\git-cmd.exe",
"terminal.integrated.shellArgs.windows": [
  "--command=usr/bin/bash.exe",
  "-l",
  "-i"
]

使用git-bash.exe作为...shell.windows,每次bash在VS!

谢天谢地终于成功了!!否则,我计划彻底清除VS并重新安装它(让我重新安装我的所有扩展并重新进行自定义!)

票数 19
EN

Stack Overflow用户

发布于 2021-08-24 15:34:56

Visual可以检测并列出配置Git Bash菜单中安装的Terminal: Select Default Profile,就像许多其他答案已经描述的那样,但我从未遇到过这种情况。对于那些不像我这样幸运的人,您可以手动将自定义配置文件添加到Visual代码的settings.json中:

代码语言:javascript
运行
复制
{
    // Tested in Visual Studio Code version 1.58.2, 1.59.1
    // Notice: my git install path is `D:\Git\bin\bash.exe`

    //"terminal.integrated.shell.windows": "D:\\Git\\bin\\bash.exe",
    // This works fine for me for a long time,
    // but in latest versions this is reported as deprecated,
    // you can keep this and sometimes Visual Studio Code will prompt to help
    // `migrate` it into new setting.

    // This part can be generated by Visual Studio Code
    "terminal.integrated.profiles.windows": {
        // This seems to be a reserved profile name, and also does not work for
        // me
        "Git Bash": {
            "path": "D:\\Git\\bin\\bash.exe",
            "icon": "terminal-bash"
        },
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell"
        },
        "Command Prompt": {
            "path": [
                "${env:windir}\\Sysnative\\cmd.exe",
                "${env:windir}\\System32\\cmd.exe"
            ],
            "args": [],
            "icon": "terminal-cmd"
        },

        // Add your custom one with a different profile name from "Git Bash"
        "gitbash": {
            "path": "D:\\Git\\bin\\bash.exe",
            "icon": "terminal-bash"
        }
    },
    // Set the custom profile as default
    "terminal.integrated.defaultProfile.windows": "gitbash",

    // ...
}
票数 16
EN

Stack Overflow用户

发布于 2018-02-07 03:06:20

我遵循了Paul DeCarlo的DeCarlo,使用了(WSL)中的Bash,而不是Git附带的Bash。它们与答案中的上述步骤相同,但在用户设置中使用下面的步骤。

"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe",

这对我来说是第一次。这对这些东西来说是很少见的。

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42606837

复制
相关文章

相似问题

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