VSCode终端 + Git Bash中任何命令都提示"command not found"

5
我的settings.json非常简单,它用sh.exe(来自git)替换了cmd.exe。
{
    "terminal.integrated.shell.windows": "C:\\Program Files (x86)\\Git\\bin\\sh.exe"
}

打开终端后,所有内容都无法正常工作。我甚至无法运行 ls 命令。

sh.exe"-3.1$ ls
sh.exe": ls: command not found
sh.exe"-3.1$ cd ..
sh.exe"-3.1$ ls
sh.exe": ls: command not found
sh.exe"-3.1$

VSCode不能与Mingw32(Git的bash)一起使用吗?我该如何设置才能让它工作?

1个回答

21

因此,Git Bash需要两个参数--login和-i。

因此,完整的JSON应该如下所示:

{
    "terminal.integrated.shell.windows": "C:\\Program Files (x86)\\Git\\bin\\bash.exe",
    "terminal.integrated.shellArgs.windows": ["--login","-i"]
}

这将使所有命令在集成终端中工作。


对于那些在Windows中无法在VSCode中使用Bash别名的人,可以在设置中添加“terminal.integrated.shellArgs.windows”: [“--login”,“-i”]。确保在执行此操作后按F1>重新加载窗口。 - Sharukh Mastan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接