16 Apr 2020

Change the default integrated shell and chose where it opens in Visual Studio Code (VS.Code)

Here's how to change to default shell (PowerShell on Windows) to whatever else you'd like. In my example, this will be to Bash from PowerShell in a Windows environment. And while we are there, I will also show you how to get your shell to open to the current file's directory instead of the project home.

Assuming, you have VS.Code running, here goes.

Open the Settings (JSON) File

I've found that the easiest way to do this is via the Command Palette (Ctrl+Shift+P) and searching for "terminal default" (without the quotes).

VS.Code Command Palette
Which should give you the "Terminal: Select Default Shell" item. Select/ click it. You should now be presented with a list of available options.

Pick the default shell
Pick one and you are set!

Optionally: Change where your integrated shell opens by default

This does take a couple of steps. Summon up your command palette again and search for "open settings json"

VS.Code Command Palette - search
Pick "Preferences: Open Settings (JSON)" - which will change the default shell for all present and future workspaces. Pick "Preferences: Open Workspace Settings (JSON)" to do this for just your present workspace.

This opens up a settings JSON file. Add the line shown below to the end of the file. If necessary, remember to add the comma at the end of the preceding line to make sure the JSON remains valid

Add a "terminal.integrated.cwd" to the end of the file

Now when you open a file and open a integrated shell (Ctrl+' in windows) it should open a prompt in the same folder as the file you've opened.

Enjoy!

Source: VS.Code help article

Did this help? Something needs fixing or anything else - comment in the box below.