【问题标题】:How to open local terminal when running VSCode in a Dev ContainerHow to open local terminal when running VSCode in a Dev Container
【发布时间】:2022-12-02 11:32:06
【问题描述】:

I'm writing code with VSCode from inside a VSCode container.

I can open terminals inside the dev container, but I can't figure out how to open a (VSCode integrated) terminal in my local machine.

I can of course open a separate terminal application like iTerm2, but it's far more convenient to use VSCode's integrated terminal panel. Is opening a local terminal possible with VSCode dev containers?

【问题讨论】:

  • I don't think that's possible. But could you maybe ssh from the dev container to your local machine?
  • @carlfriedrich Yeah that's true. Not as convenient, but should be possible.
  • I have posted an answer to make this more convenient.
  • Did that work for you?

标签: visual-studio-code vscode-remote


【解决方案1】:

Provided that you have key-based SSH access from the container to the host, you can add a terminal profile to your remote settings (run command Preferences: Open Remote Settings (JSON) (Dev Container) to open them):

{
    "terminal.integrated.profiles.linux": {
        "bash (Host)": {
            "path": "ssh",
            "icon": "terminal-bash",
            "args": [
                "user@host",
            ],
        },
    },
}

This will get you an according bash (Host) entry in your "Add Terminal" drop-down menu:

【讨论】:

    【解决方案2】:

    This solution is provided in the Accepted Answer on this SO question, so if the below helps, go and upvote that.

    Using the command palette (default ctrl+shift+p/cmd+shift+p), there is an option

    Terminal: Create New Integrated Terminal (local)

    【讨论】:

      猜你喜欢
      • 2022-12-26
      • 2022-12-27
      • 2023-02-14
      • 2022-12-28
      • 1970-01-01
      • 2022-12-02
      • 2022-12-02
      • 2022-12-01
      • 2022-12-16
      相关资源
      最近更新 更多