Bring Your Own Shell (Update 1.9 for VS Code)

Don’t like the new default shell? VS Code makes it easy to choose your own

I received the recent update for VS Code with pleasant surprises for the Integrated Terminal! Most importantly, it now defaults to Powershell. This can be changed using VS Code settings. This ability is not necessarily a new option within VS Code but, if you rather your own shell, then here we go!

Accessing Settings

To access VS Code settings, use the menu under File > Preferences and click Settings. A settings.json file opens with a list of Default Settings. These can be copied to your workspace or user settings.

With the Settings open, finding settings is easy – just type the setting name (or scroll) as shown in Figure 1.

settingsjson
Figure 1: Looking for ‘shell’ commands in settings.json

Bring Your Own Shell

According to VS Code Documentation, a different shell executable can be used given that it adheres to this very important requirement:

..the shell executable must be a console application so that stdin/stdout/stderr can be redirected..

This offers a lot of flexibility to support your given scenario and preferences. Update the shell using the format: “terminal.integrated.shell.platform”: “full path to shell executable”. For example, when specifying the setting for Windows this would be similar to:

"terminal.integrated.shell.windows":
   "C:\WINDOWS\Sysnative\WindowsPowerShell\v1.0\powershell.exe"

Shell Arguments

Arguments can be passed to this executable using the following format: “terminal.integrated.shellArgs.platform”: [“arg1”, …]. Specifying the setting for Windows would be similar to:

"terminal.integrated.shellArgs.windows": ["Get-Help", "*"]

-or-

"terminal.integrated.shellArgs.windows": ["Get-Help *"]

With those sample arguments, the terminal window will close after the help text displays for Powershell. While that is less than useful, the settings are there for your benefit. Choose the shell you want within VS Code and configure it accordingly. Of course, make sure you first have it installed.

Platforms

I’m sure you all noticed the “platform” placeholder within the setting formats. At the time of this writing, the platforms for terminal settings specified within VS Code are:

  • linux
  • osx
  • windows

VS Code is awesome, what do you think? I am eager to hear of your experiences using Visual Studio Code!

Leave a Reply