top of page
Search
  • Writer's pictureShannon

Use Multiple Terminals - Visual Studio Code

As someone who is writing more and more code, I have been trying to embrace Visual Studio Code (VS Code) over Visual Studio (I can hear my developer friends cheering me on). The extensions + overall engineering have really stepped up their proverbial game in recent months/years. I have to say I'm regularly amazed and figured this post might be helpful for those of us who are dabbling, fiddling, and trying to make themselves better with code or even cloud.


The integrated terminal for VS Code is great, but I'm mostly on my Windows machine. This means the app automatically loads PowerShell whenever I launch the program. I predominantly use Windows 10 and have become more accustomed to using Windows Subsystem for Linux (WSL) as a result (I can now hear my Linux friends cheering me on). Couple that with the Azure CLI and I determined I needed a way to run multiple terminals within VS Code.


Unfortunately I felt the documentation lacked clarity. After digging, I found an answer that sort of set me off on the right foot within Stack Overflow. I figured it might make sense to document what I did in the event it helps someone else (or until there's an extension that automagically configures everything I describe).


First off, I went and downloaded the ShellLauncher extension. Once installed, make sure you reload VS Code (P.S. I'm fairly confident that's what you need to do for any extension you install, just to be 110% safe). From there, go to File --> Preferences --> Settings --> Scroll down and find "Edit in settings.json." Because I do not edit this file often, I simply typed "edit in settings.json" in the top search bar and selected "Edit in settings.json," as I've highlighted below:

If you're savvy and remember file paths (I don't remember them as well as I used to), you can also head here to open up settings.json: %APPDATA%\Code\User\settings.json. Ultimately there are multiple ways to access this file and each gets you the same end result.


Once settings.json is open in VS Code, you may see text displayed (and that's ok). We are going to add text in versus remove text. If you see "terminal.integrated.shell.windows:", use a carriage return underneath and type this in:

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

To give you a frame of reference, here is how my terminal settings show up on my main machine:

Additionally, if you're on Linux or Mac, you can use shellLauncher.shells.linux for Linux or shellLauncher.shells.osx for macOS. All SHOULD work the same, but note I have not tested this myself.


Groovy? Let's move forward.


Next, we need to find (and possibly create) the keybindings.json file. Why? Well we're going to create a keyboard shortcut to launch multiple terminals (P.S. maybe devs have all of this handy and at their disposal, but I had to dig a bit to make this all work). You will need to go through similar steps as above, however I could not locate keybindings.json within the settings menu of VS Code (if you know how, comment below and I'll edit this post). I decided to go to %APPDATA%\Code\User\ and created the keybindings.json file (because it didn't exist). Open up keybindings.json in VS Code and type this in, somewhere within the many different keyboard shortcuts:

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

So each time I hit control + alt + back tick (which is `), a WSL terminal will load up within VS Code. As a frame of reference, here is what my keybindings.json file looks like (the file is long, so I stuck the code in toward the top - also don't forget the comma at the end):

To be safe, reload VS Code. Select Terminal from the top menu bar and then New Terminal. Once the terminal loads, type in control + alt + ` and WSL should be what it shifts to for the active terminal.


Before the keyboard shortcut is pressed (take note of the terminal number):

After the keyboard shortcut is pressed (take note of the terminal number):

HOPEFULLY that helped you out! Feel free to let me know in the comments below and be sure to share this out if you think it may help others!


Happy VS Code(ing)!

Recent Posts

See All
bottom of page