109

Can we add multiple different terminals in Visual Studio Code?

I am planning to add following three terminals and work with all of these:

  1. Windows Command prompt
  2. PowerShell
  3. Git Bash

I know I need to add the following command in PreferencesSetting:

 // // 64-bit cmd if available, otherwise 32-bit
 "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe",
// // 64-bit PowerShell if available, otherwise 32-bit
 "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
// // Git Bash
 "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",

I want to add all of the above three commands in setting.json

Enter image description here

And when I click + different terminal should open and I want to work with those terminals without changing the preferences. Is it possible in Visual Studio Code or not?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
MANISH KUMAR CHOUDHARY
  • 3,396
  • 3
  • 22
  • 34
  • 1
    If you type this into the powershell terminal it will launch the git bash: `& "c:\Program Files\git\bin\bash.exe"` – Davos Nov 22 '17 at 00:02
  • Related post - [How to change the integrated terminal in visual studio code or VSCode](https://stackoverflow.com/q/40487445/465053) – RBT Jun 17 '18 at 00:42
  • 2
    As of https://code.visualstudio.com/updates/v1_35 you can now do this more easily, see my answer totally at the bottom of the page. I ended here via google, installed the extension, then read all the way down, noticed the comment by Neil, then went to the release note of may 2019 and added it here as a fyi – edelwater Jul 11 '20 at 05:03
  • In 2022 the most appropriate answer is https://stackoverflow.com/a/69748852/7992600 – brunoff Aug 18 '22 at 02:42

12 Answers12

119

There is a way to make this happens with these steps by installing an extension:

  1. Find an extension called Shell launcher and install it or you can find it here. Reload Visual Studio Code if you want or after you finished all steps.

  2. Go to FilesPreferencesSettings and this will open the settings.json file and you then insert this (you can edit this to your heart's content):

Code:

"shellLauncher.shells.windows": [
    {
        "shell": "C:\\Windows\\<sysnative>\\cmd.exe",
        "label": "cmd"
    },
    {
        "shell": "C:\\Windows\\<sysnative>\\WindowsPowerShell\\v1.0\\powershell.exe",
        "label": "PowerShell"
    },
    {
        "shell": "C:\\Program Files\\Git\\bin\\bash.exe",
        "label": "Git bash"
    },
    {
        "shell": "C:\\Windows\\<sysnative>\\bash.exe",
        "label": "WSL Bash"
    }
]

PS: You can use shellLauncher.shells.linux for Linux or shellLauncher.shells.osx for macOS.

  1. Go to FilesPreferencesKeyboard Shortcuts and then find on the {} icon on the top right corner to open the keybindings.json file. Insert this:

Code:

[
    { "key": "ctrl+alt+`", "command": "shellLauncher.launch" }
]

Type shelllauncher into the search bar. You can then see the Shell Launcher: Launch command. Highlight and use any keybinding you like. For example, I picked Ctrl + Alt + ` (backtick) for myself.

You can reload your Visual Studio Code and click the key combination you have assigned and that will give you the option to choose which integrated terminal you want to use.

Enter image description here

For more details, please check the official site: Shell launcher

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ian0411
  • 4,115
  • 3
  • 25
  • 33
  • 10
    this is not working. I want to add multiple `terminal.integrated.shell.windows` not `Shell launcher` – MANISH KUMAR CHOUDHARY Jun 16 '17 at 18:03
  • 2
    I don't think this can be done right now but maybe in the future as Ben pointed out. This is just a work around to have multiple terminals by installing an extension with some tweaks so you can have cmd, powershell or bash opened at the same time. – ian0411 Jun 19 '17 at 13:13
  • 2
    Man this is really cool extension and actually is really what I need because sometimes I need a bash and multiple PS. Great! – Raffaeu Sep 30 '17 at 18:21
  • 2
    Works great! Added a shell for Cmder using this method. – Steve L. Nov 14 '17 at 18:37
  • 5
    For those who'll be copy/paste settings. If you are on Windows machine in your paths replace `sysnative` to `System32` – Andrew Jan 22 '19 at 12:39
  • Works great. Although I would prefer the solution with integrated options if any working. – 3bdalla May 06 '19 at 15:23
  • Also if 32bit vscode is used on 64bit windows it will not work! There is a [bug](https://github.com/Tyriar/vscode-shell-launcher/issues/28) – jabalv Nov 09 '19 at 15:09
  • Unfortunately you can not split your terminals though. – nullmn Jan 03 '20 at 16:02
  • @nullmn, check this out. https://i.stack.imgur.com/ADwea.png. The plus sign and the split screen sign on the top right corner of the terminal window should help you. – ian0411 Jan 03 '20 at 16:33
  • Thanks for your help, but when I click the split button VS Code will simply open the default terminal to the side. I want to be able to choose which one opens on the side. – nullmn Jan 03 '20 at 16:36
  • @nullmn, sorry I forgot to answer your question. I was able to do that and here is a screenshot to show you (https://i.stack.imgur.com/lauMc.png). Basically, there is no issue to open the first terminal which you can have anything you want. Then you click the `+` to add a new terminal that you want. Now you need to select back to the first terminal in the drop down field, then you can click the `split screen` sign. That should give what you want. Try and let me know. – ian0411 Jan 09 '20 at 03:49
  • @ReZ, did you install the extension? You can also find it here (https://marketplace.visualstudio.com/items?itemName=Tyriar.shell-launcher) – ian0411 Aug 02 '20 at 03:08
  • 1
    @ian0411 thanks i installed the extension and it worked – ReZ Aug 09 '20 at 22:42
  • Didn't work for me. None of the configured shells are showing up. Looks like the configuration settings have no effect on the plugin. – Jake Aug 10 '20 at 10:47
  • Fantastic! Just where I was looking for.Thanks! – Noud Apr 08 '21 at 07:08
  • In 2022 the most appropriate answer is https://stackoverflow.com/a/69748852/7992600 – brunoff Aug 18 '22 at 02:42
76

Here is a simple, suitable and complete answer while as a development I need multiple terminals handy in a click like below:

Enter image description here

And I don't bother about their path, add another extension for what Visual Studio Code is already capable of or reload VS Shell, etc. and go to insert and set up the settings files manually.

I found this question is asked many times and almost all landed up manually setup of write some settings, etc. or sometimes only opted to get a single type of terminal. The answer of Pawan is somewhat near, but again that solution finally land up to a single terminal, going to command setup for switch terminal and this one will work for Git or any other terminal.

If you have tools installed which worked on command line like PowerShell and Git along with the default cmd prompt in Windows then the following quick three steps to get all terminals at once and switch to anyone with a click.

  1. Open terminal. It should be visible (use Ctrl + ` (backtick) or from menu ViewIntegrated Terminal)

  2. Open commands search (use Ctrl + Shift + P or from menu ViewCommand Palette...)

  3. In the command box, type "Terminal: Select Default Shell" to select this option from the drop down.

    Enter image description here

  4. As you select this option, then all the available commands which are in path will be listed below like below

    Enter image description here

  5. Just click any one which you like to add for quick access from the command list.

  6. Finally, in the terminal window, just click on the + sign next to the terminal list as shown below:

    Enter image description here

    The terminal selected in step 5 will now be added after performing step 6 to the list without removal of the earlier terminal.

  7. Repeat step 3-6 for adding any other terminal to the command list.

To work with a particular terminal, just select the required one in the terminal list of the terminal window.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
AKS
  • 1,279
  • 11
  • 27
  • 2
    This is the answer I was looking for though I accidentally discovered it. :) – Legend Nov 30 '18 at 11:07
  • 26
    This approach will overwrite default terminal every time new view is added. If Visual Studio code is used for other purposes where default terminal should remain same, this is not preferable approach. – Fabio Jan 11 '19 at 23:14
  • 1
    Thanks...exactly what I was looking for. – Tiki Mar 07 '19 at 21:08
  • 3
    Is there a way to make the settings stick? It looks like the setting goes away on browser close. – Monkey Apr 10 '19 at 17:55
  • 2
    Thank you. I like native solutions. – Greeso Apr 26 '19 at 23:49
  • 1
    Not the solution. I want to fire up VSCode and get to work. I know this is a work around, but it requires a bunch of steps. I want to, like the OP suggests, just have the options right there. They've located the spot. What it should be is an array, perhaps with a preferred or default to open to. But, I want what the OP says. I want every session to have the dropdown populated without all the trickery. – Neil Gaetano Lindberg Jan 29 '20 at 21:52
  • 1
    To be fair, this answer would have used what I've added below if it were available at the time. Now, the dropdown on the terminal window includes `Select Default Shell`. – Neil Gaetano Lindberg Jan 29 '20 at 22:26
27

Press Ctrl + Shift + ` shortcut, or press a cross sign to run a new terminal. Then type bash if your default mode is PowerShell or powershell if your default mode is Bash. And here you are, your terminal is switched.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Wachburn
  • 2,842
  • 5
  • 36
  • 59
  • 1
    This does work well, but it doesn't carry over between VSCode sessions since it doesn't make any changes to settings. Personally I like this since it's only a couple of key strokes and I don't always need multiple terminal types. – torpy Feb 08 '18 at 20:07
  • 6
    This is the best solution so far – Pakk Feb 14 '18 at 16:03
  • I came here looking for exactly this answer, thank you! I wish hovering over the `+` would show the keyboard shortcut! – dossy Jan 13 '22 at 19:26
7

For now, Visual Studio Code supports defining only one of available terminals as the default at a time, and you can not add multiple shell terminals.

If you don't want to install the "Shell Launcher" plugin as suggested by @ian0411 then here is a quick way to change/select default terminal.

Press Ctrl + Shift + P to open the Command Palette.

Type "Terminal: Select Default Shell" and hit Enter. You will be prompted to select Git Bash, PowerShell or Cmd as shown below:

Option to change preferred terminal shell

Note: This will change the default shell terminal, but there isn't any harm changing it whenever you need to use another.

BTW, if you need to switch only between Cmd & PowerShell, then you can type cmd or powershell (in an already-opened terminal) to switch to the desired terminal. But it would not work for Git Bash.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Pawan
  • 91
  • 1
  • 6
5

I don't see this in the previous answers, but I read all the answers. I think this is the best approach for what is supported right now. I believe, like myself, the OP simply wants to open Visual Studio Code, and down there on the terminal window, we just want a list of options to open from.

Yes, you can open the command, "Terminal: Select Default Shell" and loop through that to add various types of terminals...

Yes, you can open the command, "Terminal: Select Default Shell" and loop through that to add various types of terminals...

Followed by:

Enter image description here

I don't know when this option was added to the dropdown, but look! There isn't any need to start by looking up the command. I think this is a lot smoother than any other answer, but it still results in the annoying overwrite of your default terminal to whatever your last choice was before leaving session.

Here, we can more easily open the Select Default Shell. It should support "Select New Shell". Simple, you'd think. Hopefully someone adds that soon or I have time to contribute.

Here, we can more easily open the "Select Default Shell" - it should support "Select New Shell"

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Neil Gaetano Lindberg
  • 2,488
  • 26
  • 23
4

I'm fairly certain that these are old-style settings.json and won't work as discussed in Visual Studio Code 2021. The new style looks like:

...
"terminal.integrated.profiles.windows":
{   "Bash":
    {    "path": ["C:\\Programs\\Git\\bin\\bash.exe"],
         "icon": "terminal-bash",
    },
    "Command Prompt":
    {   "path": ["${env:windir}\\System32\\cmd.exe"],
        "args": [],
        "icon": "terminal-cmd"
    },
    "PowerShell":
    {   "path":  ["C:\\Programs\\PowerShell\\pwsh.exe"],
        "source": "PowerShell",
        "args": [],
        "icon": "terminal-powershell"
    },
},
"terminal.integrated.defaultProfile.windows": "Bash"
...

That will get you access to Command and PowerShell and set Bash as the default shell (my preference). If you want to launch a standalone application like Git Bash, you will need something else.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
DarkSky
  • 47
  • 2
3

As of version 1.35, you can now:

  1. select "Select Default Shell" from the pulldown menu directly above the terminal
  2. select the one you like
  3. click the +
  4. done

(The same goes for opening the split screen: before this, do 1 + 2 and then click the split screen button.)

(Although it is overriding the default, but it does no longer matter if this is your flow.)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
edelwater
  • 2,650
  • 8
  • 39
  • 67
2

This can be done by adding a different key at the end. By just changing your example to:

// // 64-bit cmd if available, otherwise 32-bit
 "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe",
// // 64-bit PowerShell if available, otherwise 32-bit
 "terminal.integrated.shell.windows2": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
// // Git Bash
 "terminal.integrated.shell.windows3": "C:\\Program Files\\Git\\bin\\bash.exe",

Note that the key ...shell.windows is changed to ...shell.windows2 and ...shell.windows3.

Follow-up finding: I've noticed that once restart of the IDE, only the first terminal gets displayed. I had to reopen the settings and save it once to get both the terminals again. Will post if any better solution available.

Shiyaz
  • 488
  • 5
  • 16
  • 5
    I added these settings to UserSetting, but there's a warning on the 2nd & 3th shells, the message of warning is "Unknown configuration setting" – Emad Armoun Nov 12 '17 at 09:26
1

In the terminal tab, there's a Split Terminal button. It works like a charm.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
yonih
  • 517
  • 4
  • 15
1

To open multiple terminals, please check the screenshot for the same (on the right bottom of the Visual Studio Code there will be a dropdown and just after it, there is the + (plus) icon. On pressing it, the new terminal will open.).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • The screenshot is practically ***unreadable***. Can you resize the window first, etc. and resubmit it? (But *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***[without](https://meta.stackexchange.com/a/131011)*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** "Edit:", "Update:", or similar - the answer should appear as if it was written today.) – Peter Mortensen Aug 09 '23 at 20:29
1

The recommended way to automatically open multiple terminal windows is to use the Tasks feature. See Automating launching of terminals in the Visual Studio Code documentation.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Welt Fahr
  • 492
  • 5
  • 8
0

For WSL Ubuntu on Windows terminal:

File -> preferences -> settings -> click code icon in top right

Enter the following:

{
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\wsl.exe",
    "git.enableSmartCommit": true
}
  • Is it possible to use VSCode to do remote SSH where the destination IP & PORT are dynamic. I have a requirement to connect to remote serverB via serverA. When I login to serverA, I am redirected to serverB based on sshd_configs on serverA. when I do ssh via cmd line it goes fine to serverB. But VSCode is not able to do that. Any ideas? – Arun Chandramouli Apr 20 '22 at 08:02