11

How do the change the shell used for VS Code's integrated terminal when I connect to an remote ssh workspace?

3 Answers 3

15

Adding to @Matt Bierner's answer.

The newer versions of vscode now lets you set up profiles for your terminal and give them your custom name and that name is supposed to be referenced in your remote settings.

CTRL+SHIFT+P -> Preferences: Open Settings (JSON)

user configs

...
"terminal.integrated.profiles.linux": {
    "s-mann-term": {
        "path": "/usr/bin/zsh"
    },
    "bash": {
        "path": "bash"
    },
    "zsh": {
        "path": "zsh"
    },
    "my-fav-term": {
        "path": "fish"
    }
},
"terminal.integrated.defaultProfile.linux": "s-mann-term"
...

This will make all hosts to default to /usr/bin/zsh (I just used path key in my profile but there are bunch of other options that you can modify)

NOTE: You can add multiple profiles for the same shell as well. For example, 5 differently configured zsh profiles.

CTRL+SHIFT+P -> Preferences: Open Remote Settings (SSH: az-box1)

az-box1 configs

...
"terminal.integrated.defaultProfile.linux": "my-fav-term"
...

But az-box1 will default to fish

3
  • 2
    For the newer versions of vscode, this answer is the right answer!. Thanks
    – Dvir Itzko
    Sep 1, 2021 at 16:27
  • Can you clarify why you have /usr/bin/zsh for s-mann-term and just zsh for zsh profiles?
    – j7skov
    Jul 25, 2022 at 14:26
  • I am asking because if I use terminal.integrated.shell.linux in my remote settings.json it works, but this solution (above) does not.
    – j7skov
    Jul 25, 2022 at 14:44
12

You can use remote setting to change the shell for each host. To do this, open the remote workspace in VS Code and run the Open Remote settings command:

The Open Remote Settings commands

Set terminal.integrated.shell.linux to point to your shell and save the file:

"terminal.integrated.shell.linux": "/usr/bin/fish"

enter image description here

The remote settings apply to all workspaces you open on a given host, but must be configured for each host you connect to.

1
  • 2
    this is deprecated now. The new feature settings are using terminal.integrated.profiles.linux Nov 29, 2021 at 3:24
1

None of the above answers worked for me and I've been trying to get the default shell to be zsh for many months. What finally worked was adding the following to the top of my .bashrc:

if [[ "$TERM_PROGRAM" == "vscode" ]]; then
  # ~/.profile is run by the login shell (this is what ssh uses)
  # ~/.bashrc is run by the interactive shell (this is what vscode uses)
  # Therefore, we only need to change the shell to zsh here since
  # vscode will run ~/.bashrc for us.
  exec zsh -l
fi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.