bash VSCode 集成终端不加载 .bashrc 或 .bash_profile
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51820921/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VSCode Integrated Terminal Doesn't Load .bashrc or .bash_profile
提问by Undistraction
I have the following files to handle shell configuration:
我有以下文件来处理 shell 配置:
#~/.bash_profile
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
and
和
#~/.bashrc
... configure shell
If I open VSCode from the command line using code
, my .bashrc
is loaded whenever I add a new instance of the integrated shell.
如果我使用从命令行打开 VSCode code
,.bashrc
则每当我添加集成 shell 的新实例时都会加载my 。
However if I open VSCode via its icon, only my .profile
is loaded.
但是,如果我通过其图标打开 VSCode,则只会.profile
加载我的。
How can I ensure my .bashrc
is loaded instead?
我怎样才能确保我的.bashrc
被加载了?
I've tried various settings for the terminal.integrated.shellArgs.osx
setting without any luck.
我已经尝试了各种设置,但terminal.integrated.shellArgs.osx
没有任何运气。
采纳答案by Tony Ly
回答by Jose Ananio
Simply add shell args to the settings. Tested on Windows with git bash but it should work same on Osx and Linux.
只需将 shell args 添加到设置中。在 Windows 上使用 git bash 进行测试,但在 Osx 和 Linux 上应该可以正常工作。
In C:\Users\<username>\AppData\Roaming\Code\User\settings.json
or where your windows setting is:
Add one of the following:
在C:\Users\<username>\AppData\Roaming\Code\User\settings.json
或在您的Windows设置是:添加以下之一:
"terminal.integrated.shellArgs.windows": ["-l"],
"terminal.integrated.shellArgs.linux": ["-l"],
"terminal.integrated.shellArgs.osx": ["-l"],
just below "terminal.integrated.shell.<platform>...
略低于 "terminal.integrated.shell.<platform>...
This will launch bash with the login argument.
这将使用 login 参数启动 bash。
回答by curi0uz_k0d3r
You could also try the following:
您还可以尝试以下操作:
1 Create a file named /usr/local/bin/bash-login and add :
1 创建一个名为 /usr/local/bin/bash-login 的文件并添加:
#!/bin/bash
bash -l
2 Run:
2 运行:
chmod +x /usr/local/bin/bash-login
to make it executable.
使其可执行。
3 On your VSC user settings add
3 在您的 VSC 用户设置中添加
{ "terminal.integrated.shell.osx": "/usr/local/bin/bash-login" }
The solution was described at https://github.com/Microsoft/vscode/issues/7263.
该解决方案在https://github.com/Microsoft/vscode/issues/7263 中有所描述。
Hope it helps
希望能帮助到你
回答by user3091644
Another possible solution that just worked for me. The settings.json file (whcih you can access in File > Preferences > Settings > Features > terminal > Integrated > Automation Shell: Linux) had a parameter
另一种可能对我有用的解决方案。settings.json 文件(您可以在“文件”>“首选项”>“设置”>“功能”>“终端”>“集成”>“自动化外壳:Linux”中访问)有一个参数
"terminal.integrated.inheritEnv": false
set to false by default. Changing it to true fixed the problem in my case.
默认设置为false。将其更改为 true 解决了我的问题。