Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure a different shell for a VS Code SSH Remote?

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

like image 496
Matt Bierner Avatar asked May 03 '19 23:05

Matt Bierner


People also ask

How do I connect to a remote server using Visual Studio code?

Connect to a remote host#In VS Code, select Remote-SSH: Connect to Host... from the Command Palette (F1, Ctrl+Shift+P) and use the same user@hostname as in step 1. If VS Code cannot automatically detect the type of server you are connecting to, you will be asked to select the type manually.


2 Answers

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.

like image 143
Matt Bierner Avatar answered Oct 17 '22 20:10

Matt Bierner


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

like image 25
Sukhinderpal Mann Avatar answered Oct 17 '22 18:10

Sukhinderpal Mann