512

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?

3

13 Answers 13

896

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).

Terminal Selection 3

Older:

Terminal Selection

Terminal Selection

Sign up to request clarification or add additional context in comments.

7 Comments

As of today on MacOS the Terminal extension does not have a "Select Default Shell" option in the menu! Lucky for me using stackoverflow.com/a/49916667/99834 worked.
I'm using MacOS Catalina right now, "Terminal: Select Default Shell" was there and worked for me.
Updated Answer for Linux and MAC: askubuntu.com/a/1118140/810954
Has this changed because I have done this on Windows version 1.65.2 and every time there is a restart, I get the powershell instead of Git bash
2023: >select terminal profile is the command
|
122

Configure your default integrated terminal by running the Terminal: Select Default Profile command, which is also accessible via the terminal dropdown.

Enter image description here

See Terminal Basics.

6 Comments

This is the correct and most recent way of doing it, however, it doesn't work for me in VS Code v1.56.2. This works "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\bash.exe"
When im trying to use "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\bash.exe" Im getting this warning - "This is deprecated, the new recommended way to configure your default shell is by creating a terminal profile" (VS Code v1.56.2)
I’m getting the same deprecated warning but at least it works. Like I said recommended way isn’t working for me on v1.56.2.
Not work for me in VSCode 1.56.2 too. Use deprecated way, it works.
There is a Small drop down that says Select Default Profile... that sets the current shell as the default profile.
|
54

I just type the following keywords in the opened terminal;

  1. powershell
  2. bash
  3. cmd
  4. node
  5. python (or python3)

See details in the below image (Visual Studio Code version 1.19.1 on the Windows 10 OS):

Enter image description here

It works on Visual Studio Code Mac as well. I tried it with Visual Studio Code (version 1.20.1).

2 Comments

Seems to work only when bash is selected as default shell.
Was searching for a way to open my wsl on windows without changing the default, creating new, then switching default back to powershell. Simply typing wsl works an absolute charm
48
  1. Just press Ctrl + Shift + P
  2. Search "Terminal: Select Default Profile". Click
  3. You will see terminals options and select Git Bash

Comments

39

Go to menu FilePreferencesSettings (or press Ctrl + ,). Then click the leftmost icon in the top right corner, "Open Settings (JSON)"

Screenshot showing location of icon

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.

4 Comments

It appears that VSCode has changed a little since this answer, now there is a button with {} on it that you must press to get to the editor to make this change. The command in this answer did work correctly. Thank you for the answer.
You should not use the executable from System32 since (normally) vs code has no access to that executable. Instead use the program files one 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.
I have terminal.integrated.defaultProfile.linux and terminal.integrated.defaultProfile.windows and terminal.integrated.defaultProfile.osx. The magic three..
10

To change the default terminal for your project in Visual Studio Code:

  1. Create a folder by name of .vscode
  2. Create a settings.json file in this folder:
  3. Write the settings you want

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

Enter image description here

Comments

6

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.

Comments

5

Going off of arielhad's solution...

My Visual Studio Code version was 1.57.1.

Open the settings.json file:

  • Ctrl + Shift + p
  • Type 'Open Settings (JSON)' and select.

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.

1 Comment

This was the case for me. "Git Bash" seems to be a reserved keyword or it's not working with space in it. GitBash worked for me.
5

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 TerminalIntegratedDefault Profile: Linux section, so you can pick your favorite one.

Linux Terminal Profiles

3 Comments

It should be the correct answer, because the OP wants to switch from Windows to Linux in Vscode which is only possible with Remote WSL I guess.
I set fish as default shell on wsl, but vscode still used bash. Set this setting explicitly and now it works like a charms, ty!
how to have PowerShell on the list when opening project in WSL?
2

Press Ctrl + Shift + P. Then type settings.json.

At the end of the file, change the 'PowerShell' to 'Git Bash'.

1 Comment

Lol, what makes this answer different from @OneShadow 's answer. Please elaborate more on it.
2

The integrated shell option still works, but it has been deprecated. The fix is to use the integrated profile instead:

    "terminal.integrated.profiles.windows": {
        "C:\\Program Files\\Git\\bin\\bash.exe (migrated)": {
            "path": "C:\\Program Files\\Git\\bin\\bash.exe",
            "args": []
        }
    }

Comments

1

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 FilePreferencesKeyboard 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"
}

1 Comment

Without this extension Shell launcher this answer is useless. So just install it and specify shortcut. Be careful, this shortcut is already defined - find this shortcut and check if you use action under this shortcut or not.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.