#原始但不能100%正常工作(被接受为答案)
这将正确启动MSYS2 bash shell,以便执行您的.bash_login:
"terminal.integrated.shell.windows": "C:\\msys64\\msys2_shell.cmd",
"terminal.integrated.shellArgs.windows": ["-defterm", "-mingw64", "-no-start", "-here"]
#编辑
原始答案在当时似乎是有效的,但当我尝试在VSCode中开始使用任务时,显然它并没有起作用。尝试运行一个简单调用make all的任务会导致以下错误:
/usr/bin/bash: /d: 没有那个文件或目录
终端进程以退出代码127终止
根据其他答案,使用"terminal.integrated.shellArgs.windows": ["--login", "-i"]
可以获得几乎正确的环境(MSYS而不是MINGW64),但是它在错误的目录中启动,而"terminal.integrated.shellArgs.windows": ["-lic", "cd $OLDPWD; exec bash"]
则在正确的目录中以正确的环境启动,但无法运行任务。
我想出了这个解决方案,到目前为止似乎工作正常。
在VSCode设置中:
"terminal.integrated.shell.windows": "C:\\msys64\\usr\\bin\\bash.exe",
"terminal.integrated.env.windows":
{
"MSYSTEM": "MINGW64",
"MSVSCODE": "1"
},
在
.bashrc 文件中:
if [ ! -z "$MSVSCODE" ]; then
unset MSVSCODE
source /etc/profile
cd "${OLDPWD}"
fi
terminal.integrated.shell.windows
的设置已经指向terminal.integrated.profiles.windows
。 - Abel Cheung