VSCode集成的终端无法加载.bashrc或.bash_profile文件。

10 浏览
0 Comments

VSCode集成的终端无法加载.bashrc或.bash_profile文件。

我需要处理shell配置的以下文件:

#~/.bash_profile
if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi

#~/.bashrc
... configure shell

如果我使用code从命令行打开VSCode,每当我添加一个新的终端实例时,我的.bashrc都会被加载。

但是,如果我通过其图标打开VSCode,则仅加载我的.profile

我如何确保我的.bashrc被加载?

我已尝试各种terminal.integrated.shellArgs.osx设置,但都没有成功。

admin 更改状态以发布 2023年5月21日
0
0 Comments

VSCode已经弃用 "terminal.integrated.shellArgs.osx",建议使用profiles。这里提供bash在OSX上的操作方法。如果您不想使用bash作为默认profile,请省略第一行:

  "terminal.integrated.defaultProfile.osx": "bash",
  "terminal.integrated.profiles.osx": {
    "bash": {
      "path": "bash",
      "args": ["-l"]
    }
  }

0
0 Comments

只需将 shell 参数添加到 VsCode 的 settings.json 文件中。

settings.json 文件的路径如下:

Windows: C:\Users\\AppData\Roaming\Code\User\settings.json`
Linux:   $HOME/.config/Code/User/settings.json
Mac:     $HOME/Library/Application\ Support/Code/User/settings.json

添加以下之一:

"terminal.integrated.shellArgs.windows": ["-l"],
"terminal.integrated.shellArgs.linux": ["-l"],
"terminal.integrated.shellArgs.osx": ["-l"],

这将使用登录参数启动您选择的 shell。因此,将执行任何设置的用户配置文件。

0