VScode 终端似乎没有在 Windows 上加载 .bashrc 或 .bash_profile

Posted

技术标签:

【中文标题】VScode 终端似乎没有在 Windows 上加载 .bashrc 或 .bash_profile【英文标题】:VScode terminal doesn't seem to load .bashrc or .bash_profile on windows 【发布时间】:2019-08-02 06:04:37 【问题描述】:

如果我在 VScode 中启动一个新的集成终端,它似乎不会加载我的 .bashrc 文件。一旦终端打开,我可以 source ~/.bashrc 然后出现自定义设置。我的问题似乎与此 question 重复,但是对于 windows 而不是 osx。

是否可以让 vscode 在启动集成终端的新实例时自动获取我的 .bashrc 或 .bash_profile?

到目前为止,我已经尝试了以下方法:

我已经通过设置"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe" 将终端指向 git bash

我尝试在设置中传递一个 shell 参数,使用 "terminal.integrated.shellArgs.windows": ["-l"] 但是文档中不清楚这是否适用于 windows 或仅适用于 linux。

【问题讨论】:

您能否将您的问题表述得更好一些,以便我们能更清楚地理解它?谢谢! 我刚刚编辑了帖子。希望现在很清楚。谢谢! 【参考方案1】:

将此添加到我的 settings.json 为我解决了这个问题。

"terminal.integrated.shellArgs.windows": [
    "-l"
  ]

编辑:Derp 我不擅长阅读。如果您将 .bashrc 内容移动到 .bash_profile 文件中,它可能对您有用。

【讨论】:

以上是关于VScode 终端似乎没有在 Windows 上加载 .bashrc 或 .bash_profile的主要内容,如果未能解决你的问题,请参考以下文章

vscode (v1.57.0) 配置默认终端为git bash

Mac设置终端打开VScode

windows 修改环境变量后在 vscode 的终端不生效的解决方法

vscode配置git bash

在 VSCode 终端中运行 msys2 shell

VSCode 更改默认终端