VSCode Integrated Terminal Doesn't Load .bashrc or .bash_profile
我具有以下文件来处理外壳程序配置:
1 2 3 4 | #~/.bash_profile if [ -f ~/.bashrc ]; then source ~/.bashrc fi |
和
1 2 | #~/.bashrc ... configure shell |
如果使用
但是,如果我通过VSCode图标打开VSCode,则只会加载我的
如何确保我的
我尝试了
只需将shell args添加到设置中。在Windows上使用git bash进行了测试,但是在Osx和Linux上应该可以正常使用。
在
oaming\\Code\\User\\settings.json
添加以下之一:
1 2 3 4 5 | "terminal.integrated.shellArgs.windows": ["-l"], "terminal.integrated.shellArgs.linux": ["-l"], "terminal.integrated.shellArgs.osx": ["-l"], |
正好在
之下
这将使用登录参数启动bash。
另一个对我有用的可能解决方案。 settings.json文件(您可以在"文件">"首选项">"设置">"功能">"终端">"集成">"自动化外壳:Linux"中访问)具有参数
1 | "terminal.integrated.inheritEnv": false |
默认设置为false。将其更改为true可以解决我的问题。
我在Mac上的Intellij Idea终端上遇到了同样的问题,两者的解决方案是相同的。在设置中,将集成终端的路径更改为" / bin / bash"。希望有帮助。
您也可以尝试以下操作:
1创建一个名为/ usr / local / bin / bash-login的文件并添加:
1 2 | #!/bin/bash bash -l |
2运行:
1 | chmod +x /usr/local/bin/bash-login |
使其可执行。
3在VSC用户设置上,添加
1 | {"terminal.integrated.shell.osx":"/usr/local/bin/bash-login" } |
该解决方案在https://github.com/Microsoft/vscode/issues/7263中进行了描述。
希望对您有所帮助