Skip to content

Instantly share code, notes, and snippets.

@plembo
Last active October 28, 2020 16:54
Show Gist options
  • Save plembo/2a116930d107a6745f239be9e453953c to your computer and use it in GitHub Desktop.
Save plembo/2a116930d107a6745f239be9e453953c to your computer and use it in GitHub Desktop.
Change the default terminal shell in vscode

Changing the default terminal shell in vscode

The integrated terminal in vscode (Visual Studio Code) is a handy feature. By default it launches Windows PowerShell on Windows, and bash on Linux.

But vscode can usually detect other available shells, including the cross-platform PowerShell 7, or if you're on Windows, the humble command prompt. It is normally not necessary to manually add these to the vscode configuration.

Changing shells is as easy as typing the shell's executable name in an existing vscode terminal.

Getting vscode to open a shell other than the shipping default for your platform requires a little more effort.

You can change the default shell from within vscode by selecting it from "Select Default Shell" on the drop down menu at the upper right of a vscode terminal window. You will then be presented with a list of shells that vscode has detected to choose from.

This change will remain in force until you select a new default shell.

For those who prefer to edit settings.json directly, that can be done either through vscode itself or using another text editor.

In vscode, you would choose File... Preferences... Settings and then the "Open Settings (JSON) icon at the top right.

Outside of vscode you'll need to navigate to settings.json, which is found on Windows under

C:\Users\[username]\AppData\Roaming\Code\User

and on Linux under

/home/[username]/.config/Code/User

To have vscode's terminal open with any shell other than its shipping default, you need to add something like the following on Windows:

// PowerShell 7
"terminal.integrated.shell.windows": "C:\\Program Files\\PowerShell\\7\\pwsh.exe"

where the path is to the executable for your preferred shell.

On Linux the only differences are the module name is "...shell.linux" and the filesystem path:

// PowerShell 7
"terminal.integrated.shell.linux": "/usr/bin/pwsh"

In my own setup on Windows, I've changed the default vscode terminal shell to PowerShell 7. On Linux, I've left it unchanged (because I prefer bash).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment