I am using Visual Studio Code on my Windows 10 PC. I want to change my default terminal from Windows PowerShell to Bash on Ubuntu (on Windows).
How can I do that?
I am using Visual Studio Code on my Windows 10 PC. I want to change my default terminal from Windows PowerShell to Bash on Ubuntu (on Windows).
How can I do that?
You can also select your default terminal by pressing F1 in Visual Studio Code and typing/selecting Terminal: Select Default Profile (or Terminal: Select Default Shell in older Visual Studio Code versions).

Older:


>select terminal profile is the commandConfigure your default integrated terminal by running the Terminal: Select Default Profile command, which is also accessible via the terminal dropdown.
See Terminal Basics.
I just type the following keywords in the opened terminal;
See details in the below image (Visual Studio Code version 1.19.1 on the Windows 10 OS):
It works on Visual Studio Code Mac as well. I tried it with Visual Studio Code (version 1.20.1).
bash is selected as default shell.wsl works an absolute charmGo to menu File → Preferences → Settings (or press Ctrl + ,). Then click the leftmost icon in the top right corner, "Open Settings (JSON)"
In the JSON settings window, add this (within the curly braces {}):
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\bash.exe"`
(Here you can put any other custom settings you want as well.)
Checkout that path to make sure your bash.exe file is there. Otherwise, find out where it is and point to that path instead.
Now if you open a new terminal window in Visual Studio Code, it should open with Bash instead of PowerShell.
terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe""terminal.integrated.shell.windows" or "terminal.integrated.shell.linux" is deprecated and it did not seem to work in my case (v1.62.0 on linux). Use "terminal.integrated.defaultProfile.windows" or "terminal.integrated.shell.linux" instead and define the executable path in the "terminal.integrated.profiles.windows" or "terminal.integrated.profiles.linux", repectively. See also @Stephanieraymos answer below.terminal.integrated.defaultProfile.linux and terminal.integrated.defaultProfile.windows and terminal.integrated.defaultProfile.osx. The magic three..To change the default terminal for your project in Visual Studio Code:
For example, if you are a Windows user and want to set "Command Prompt" as the default terminal you can write:
"terminal.integrated.defaultProfile.windows": "Command Prompt"
values. You can pass: "Git Bash", "PowerShell", and "Command Prompt".
For Linux, you will use terminal.integrated.defaultProfile.linux and for macOS you will use: terminal.integrated.defaultProfile.osx
You can change the terminal by opening the Command Palette by pressing Ctrl + Shift + P.
Or you can go to View at the top and click "Open Command Palette".
Then type Terminal: Select Default Profile
And you can type which terminal you want.
Going off of arielhad's solution...
My Visual Studio Code version was 1.57.1.
Open the settings.json file:
Add the following:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"path": [
"${env:windir}\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
"${env:windir}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
],
"source": "PowerShell",
"icon": "terminal-powershell",
"args": [
"-NoLogo",
"-ExecutionPolicy",
"Bypass"
]
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"icon": "terminal-cmd"
},
//START: THIS DOES NOT WORK
"Git Bash": {
"path": [
"C:\\Program Files\\Git\\bin\\bash.exe",
],
"source": "Git Bash",
"icon": "terminal-bash"
}
// END: THIS DOES NOT WORK
//START: THIS WORKS
"GitBash": {
"path": [
"C:\\Program Files\\Git\\bin\\bash.exe",
],
"icon": "terminal-bash"
}
// END: THIS WORKS
}
I don't know why the second way works, but it does. It appears the 'Git Bash' is a reserved name and I guess you cannot set the path.
Since you use WSL, Visual Studio Code has the dedicated Remote - WSL extension, so you can use a Linux environment directly in Visual Studio Code.
When you open the project inside Linux, by default, it's using the Linux default shell (bash by default), so no configuration needed.
If you want to switch to other profile, there is Terminal → Integrated → Default Profile: Linux section, so you can pick your favorite one.
Press Ctrl + Shift + P. Then type settings.json.
At the end of the file, change the 'PowerShell' to 'Git Bash'.
If you want to select the type of console, you can write this in the file keybindings.json (this file can be found in the following path: menu File → Preferences → Keyboard Shortcuts)
// With this, you can select what type of console you want
{
"key": "ctrl+shift+t",
"command": "shellLauncher.launch"
},
// And this will help you quickly change console
{
"key": "ctrl+shift+j",
"command": "workbench.action.terminal.focusNext"
},
{
"key": "ctrl+shift+k",
"command": "workbench.action.terminal.focusPrevious"
}
Change default terminal to Python/Bash
Have given example for python below, you can do similar procedure to have the bash option appear in vs code. Search for User Profile Settings (JSON) in command palette (Ctrl+Shift+P): Then copy paste this code within the curly braces:
"terminal.integrated.profiles.windows": {
"Python": {
"path": "python",
"args": []
}
}
You can change the path variable to whichever terminal you want to use.
Now, open the command palette again and search for select default terminal, your new terminal should be an option there. Select it and every new terminal will be the cmd of your choice.