Win10:VS Code 集成 bash 未加载 ~/.bash_profile

LLL*_*LLL 8 .bash-profile visual-studio-code

正如标题所暗示的那样,当我定期启动 git bash 时,它会加载我的 ~/.bash_profile 但集成在我的 VS Code 中的那个并没有加载它。

我可以将 .bash_profile 放在哪里,以便它也可以加载到 VS Code 中?

编辑:这是我的终端代码 VS代码

这是我的 git bash 混蛋

我想在我的 git bash 上加载的 vs code 终端中加载相同的 .bash_profile 文件,以便它显示分支名称并在那里定义别名。

LLL*_*LLL 8

事实证明,它必须与终端的启动方式有关。git bash 之一(在其自己的窗口中)使用登录名启动,因此读取.bash_profile.

vs 代码中的那个不是以登录方式启动的(对不起,我不精通这一点),.bashrc而是读取而不是.bash_profile.

我的解决方案是移动我保留的所有内容.bash_profile并将其移动到.bashrc并将以下行添加到.bash_profile

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
Run Code Online (Sandbox Code Playgroud)

.bashrc以登录方式启动时加载内容。


小智 5

您可以尝试在设置中添加:"terminal.integrated.shellArgs.windows": ["-l"],


作为替代方案,您可以使用该.bashrc文件而不是.bash_profile.