Using the "normal" host shell from VS Code flatpak

I use the VS Code package from Flathub, because it's convenient and frequently updated. One downside is that the integrated terminal in VS Code doesn't have access to everything installed on your host machine.

To work around this, I install an SSH server on my host machine (which I use for other things anyway), and then configure a terminal profile to connect using SSH.

First, if you haven't already, create an SSH key and authorize it to log in to your own local account. This will allow you to have a passwordless SSH session from VS Code:

ssh-keygen
ssh-copy-id localhost

Then, add an SSH profile to your VS Code configuration. To do this, press F1 and search for the command "Preferences: Open User Settings (JSON)" in the command pallette. This will open your current settings file in a new editor tab.

These are the relevant entries:

{
    ...
    "terminal.integrated.profiles.linux": {
        "ssh": {
            "path": "ssh",
            "args": ["localhost", "-t", "cd ${workspaceFolder}; bash -l"]
        },
        ...
    },
    "terminal.integrated.defaultProfile.linux": "ssh",
    ...
}

Enjoy!