Change the default terminal in Visual Studio Code
Asked Answered
E

12

437

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?

Effusive answered 8/6, 2017 at 12:23 Comment(3)
Related post here - How to use multiple types of command shell in Visual Studio code integrated terminalNeoplatonism
Does this answer your question? How to select a different type of command shell in the Visual Studio Code integrated terminalSonstrom
Re "on Windows": WSL, presumably?Inadequate
U
744

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

Utrillo answered 26/8, 2017 at 21:10 Comment(6)
As of today on MacOS the Terminal extension does not have a "Select Default Shell" option in the menu! Lucky for me using https://mcmap.net/q/80607/-change-the-default-terminal-in-visual-studio-code worked.Laplace
I'm using MacOS Catalina right now, "Terminal: Select Default Shell" was there and worked for me.Megilp
Updated Answer for Linux and MAC: askubuntu.com/a/1118140/810954Importunate
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 bashGwenny
2023: >select terminal profile is the commandChinkiang
For macOS users, just type the key SHIFT + Command + P and type terminal profile. Choose Terminal: Select Default Profile and choose your preferred terminal.Yashmak
P
104

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.

Polyphone answered 12/5, 2021 at 9:37 Comment(6)
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"Flashcube
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)Polyphone
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.Flashcube
Not work for me in VSCode 1.56.2 too. Use deprecated way, it works.Gallager
There is a Small drop down that says Select Default Profile... that sets the current shell as the default profile.Dodecanese
Not working in VSCode 1.57.1, HOWEVER, if you remove "source": "Git Bash" AND change the name from "Git Bash" to something like "GitBash", it works. Is there a bug???Superabound
C
55

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

Cerda answered 15/2, 2018 at 8:48 Comment(2)
Seems to work only when bash is selected as default shell.Spinthariscope
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 charmDasheen
S
40

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.

Sister answered 19/4, 2018 at 8:48 Comment(4)
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.Papst
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"Teets
"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.Audry
I have terminal.integrated.defaultProfile.linux and terminal.integrated.defaultProfile.windows and terminal.integrated.defaultProfile.osx. The magic three..Volplane
A
28
  1. Just press Ctrl + Shift + P
  2. Search "Terminal: Select Default Profile". Click
  3. You will see terminals options and select Git Bash
Auston answered 30/10, 2022 at 3:50 Comment(0)
D
7

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

Danube answered 20/5, 2022 at 9:59 Comment(0)
A
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.

African answered 8/4, 2021 at 17:37 Comment(0)
T
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

Twopence answered 6/1, 2022 at 5:42 Comment(3)
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.Volplane
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!Arondell
how to have PowerShell on the list when opening project in WSL?Acrylyl
S
4

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.

Superabound answered 23/6, 2021 at 20:12 Comment(0)
D
2

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

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

Disaster answered 8/6, 2017 at 12:23 Comment(1)
Lol, what makes this answer different from @OneShadow 's answer. Please elaborate more on it.Khadijahkhai
H
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": []
        }
    }
Hanford answered 30/6, 2021 at 20:52 Comment(0)
C
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"
}
Champollion answered 3/3, 2018 at 14:7 Comment(1)
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.Handpick

© 2022 - 2024 — McMap. All rights reserved.