![Win10:VS Code 集成的 bash 未加载 ~/.bash_profile](https://linux22.com/image/1530241/Win10%EF%BC%9AVS%20Code%20%E9%9B%86%E6%88%90%E7%9A%84%20bash%20%E6%9C%AA%E5%8A%A0%E8%BD%BD%20~%2F.bash_profile.png)
答案1
事实证明,这与终端的启动方式有关。git bash 终端(在其自己的窗口中)使用登录来启动,因此读取.bash_profile
。
vs code 中的启动不是通过登录的方式(抱歉,我不太熟悉这个),而是.bashrc
读取.bash_profile
。
我的解决方案是将我保存的所有内容移至.bash_profile
,.bashrc
并将以下行添加到.bash_profile
:
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
.bashrc
以登录方式启动时加载内容。
答案2
您可以尝试添加设置:"terminal.integrated.shellArgs.windows": ["-l"],
另外,您也可以使用.bashrc
文件来代替.bash_profile
。
答案3
使用 WSL(Ubuntu 16.04),我必须在 VS Code 中的 settings.json 中添加以下选项才能将 shell 作为登录 shell 运行:
"terminal.integrated.shellArgs.linux": ["-l"]
答案4
接受答案的替代方法:
在您的根目录中添加一个文件 .bashrc,其中包含以下代码:
source <rootdirectory>/.bash_profile
用您自己的根替换的地方。
例如C:/用户/domkj/.bash_profile