abhijeetps
abhijeetps

Reputation: 5650

Change the default terminal in Visual Studio Code

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?

Upvotes: 485

Views: 571750

Answers (13)

lazer_time
lazer_time

Reputation: 1

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.

Upvotes: 0

Moniruzzaman Sujon
Moniruzzaman Sujon

Reputation: 558

  1. Just press Ctrl + Shift + P
  2. Search "Terminal: Select Default Profile". Click
  3. You will see terminals options and select Git Bash

Upvotes: 42

Mustafa Poya
Mustafa Poya

Reputation: 3027

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

Upvotes: 9

Tan Nguyen
Tan Nguyen

Reputation: 1844

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

Upvotes: 5

Stephanieraymos
Stephanieraymos

Reputation: 314

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": []
        }
    }

Upvotes: 2

Chuck L
Chuck L

Reputation: 1114

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.

Upvotes: 5

arielhad
arielhad

Reputation: 2153

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.

Upvotes: 117

Mohammed Shabeer k
Mohammed Shabeer k

Reputation: 287

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

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

Upvotes: 2

MRPie
MRPie

Reputation: 295

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.

Upvotes: 6

A. Backhagen
A. Backhagen

Reputation: 1407

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.

Upvotes: 40

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

Upvotes: 1

AnandShanbhag
AnandShanbhag

Reputation: 7100

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

Upvotes: 54

Levi Fuller
Levi Fuller

Reputation: 15631

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

Upvotes: 840

Related Questions