在 vscode 中启用“作为登录 shell 运行命令”

cka*_*aus 4 visual-studio-code ubuntu-20.04

我在Ubuntu 20.04 LTS上使用 vscode 。我已将ubuntu 的终端首选项设置为Run command as login shell (bash)。现在,我打开 vs code。它还打开集成的 bash 终端。我想知道vscode 上是否也启用了“以登录 shell 方式运行命令”?

che*_*urt 15

我今天也在寻找同样的东西。我想我已经弄清楚了,因为我没有犯以前的错误。

我按照此处的文档进行操作:https ://code.visualstudio.com/docs/editor/integrated-terminal#_configuring-profiles

"terminal.integrated.profiles.linux"在 settings.json 文件中添加了一个条目,它会为每种可用的终端类型自动添加条目。我编辑了 bash 添加的终端选项卡"args": ["--login"],然后打开一个新的终端选项卡,新的终端选项卡开始工作。

以下是添加到 settings.json 的完整条目:

"terminal.integrated.profiles.linux": {
      "bash": {
        "path": "bash",
        "icon": "terminal-bash",
        "args": ["--login"]
      },
      "zsh": {
        "path": "zsh"
      },
      "fish": {
        "path": "fish"
      },
      "tmux": {
        "path": "tmux",
        "icon": "terminal-tmux"
      },
      "pwsh": {
        "path": "pwsh",
        "icon": "terminal-powershell"
      }
    }
Run Code Online (Sandbox Code Playgroud)

您可以运行shopt login_shell来验证终端是否作为登录 shell 运行。login_shell on如果是的话就会打印