【发布时间】:2019-07-01 12:36:36
【问题描述】:
我在 Windows 10 Home 上使用 VSCode 版本 1.31.0。我启用了 WSL,并安装了一些东西,如 nvm、pyenv 等,这需要在 .bashrc 和 .bash_profile 上运行所需的额外脚本
例如.bashrc:
export PATH="/custom/path:$PATH"
运行集成 shell (CTRL + `) 时,一切正常,我可以看到 $PATH 包括 /custom/path
但是当我尝试运行一个任务脚本时(https://code.visualstudio.com/docs/editor/tasks#vscode)
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "eslint",
"problemMatcher": [
"$eslint-stylish"
]
},
{
"label": "Run tests",
"type": "shell",
"command": "./scripts/test.sh",
"presentation": {
"reveal": "always",
"panel": "new"
}
}
]
}
test.sh中的内容
echo $PATH
当我尝试运行“运行测试”任务时,它不显示/custom/path,或者实际上,不包括~/.bashrc 和~/.bash_profile 中的任何内容。
我什至在 test.sh 中尝试过类似的东西,但它仍然没有加载我的 .bashrc
source /home/user/.bashrc
echo $PATH
以下是我的 VSCode 用户设置:
{
"terminal.external.windowsExec": "C:\\windows\\Sysnative\\bash.exe",
"terminal.integrated.shell.windows": "C:\\windows\\Sysnative\\bash.exe",
"terminal.integrated.shellArgs.windows": ["--login"],
"eslint.provideLintTask": true
}
问题是:
如何设置 VSCode 或 windows 以使用我的 .bashrc 或 .bash_profile 运行任务?
【问题讨论】:
标签: windows bash shell terminal visual-studio-code