75

I want to change the integrated terminal to Cmder. I use Visual Studio Code on Windows 8.1.

I checked the documentation and also the preference file, but I am confused about which line to change.


External Terminal

// Customizes which terminal to run on Windows.
"terminal.external.windowsExec": "%COMSPEC%",

// Customizes which terminal application to run on OS X.
"terminal.external.osxExec": "Terminal.app",

// Customizes which terminal to run on Linux.
"terminal.external.linuxExec": "xterm",

Integrated Terminal

// The path of the shell that the terminal uses on Linux.
"terminal.integrated.shell.linux": "sh",

// The command line arguments to use when on the Linux terminal.
"terminal.integrated.shellArgs.linux": [],

// The path of the shell that the terminal uses on OS X.
"terminal.integrated.shell.osx": "sh",

// The command line arguments to use when on the OS X terminal.
"terminal.integrated.shellArgs.osx": [],

// The path of the shell that the terminal uses on Windows. When using shells shipped with Windows (cmd, PowerShell or Bash on Ubuntu), prefer C:\Windows\sysnative over C:\Windows\System32 to use the 64-bit versions.
"terminal.integrated.shell.windows": "C:\\Windows\\system32\\cmd.exe",

// The command line arguments to use when on the Windows terminal.
"terminal.integrated.shellArgs.windows": [],

// Controls the font family of the terminal, this defaults to editor.fontFamily's value.
"terminal.integrated.fontFamily": "",

// Controls whether font ligatures are enabled in the terminal.
"terminal.integrated.fontLigatures": false,

// Controls the font size in pixels of the terminal, this defaults to editor.fontSize's value.
"terminal.integrated.fontSize": 0,

// Controls the line height of the terminal, this number is multipled by the terminal font size to get the actual line-height in pixels.
"terminal.integrated.lineHeight": 1.2,

// Controls whether the terminal cursor blinks.
"terminal.integrated.cursorBlinking": false,

// Controls whether locale variables are set at startup of the terminal, this defaults to true on OS X, false on other platforms.
"terminal.integrated.setLocaleVariables": false,

// A set of command IDs whose keybindings will not be sent to the shell and instead always be handled by Code. This allows the use of keybindings that would normally be consumed by the shell to act the same as when the terminal is not focused, for example ctrl+p to launch Quick Open.
"terminal.integrated.commandsToSkipShell": [
    "editor.action.toggleTabFocusMode",
    "workbench.action.debug.continue",
    "workbench.action.debug.restart",
    "workbench.action.debug.run",
    "workbench.action.debug.start",
    "workbench.action.debug.stop",
    "workbench.action.quickOpen",
    "workbench.action.showCommands",
    "workbench.action.terminal.clear",
    "workbench.action.terminal.copySelection",
    "workbench.action.terminal.focus",
    "workbench.action.terminal.focusNext",
    "workbench.action.terminal.focusPrevious",
    "workbench.action.terminal.kill",
    "workbench.action.terminal.new",
    "workbench.action.terminal.paste",
    "workbench.action.terminal.runSelectedText",
    "workbench.action.terminal.scrollDown",
    "workbench.action.terminal.scrollDownPage",
    "workbench.action.terminal.scrollToBottom",
    "workbench.action.terminal.scrollToTop",
    "workbench.action.terminal.scrollUp",
    "workbench.action.terminal.scrollUpPage",
    "workbench.action.terminal.toggleTerminal"
],
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 2
    Related post - [How to add multiple terminal in VS Code?](https://stackoverflow.com/q/43427631/465053) – RBT Jun 17 '18 at 00:42

10 Answers10

50

To change the integrated terminal on Windows, you just need to change the terminal.integrated.shell.windows line:

  1. Open VS User Settings (Preferences > User Settings). This will open two side-by-side documents.
  2. Add a new "terminal.integrated.shell.windows": "C:\\Bin\\Cmder\\Cmder.exe" setting to the User Settings document on the right if it's not already there. This is so you aren't editing the Default Setting directly, but instead adding to it.
  3. Save the User Settings file.

You can then access it with keys Ctrl+backtick by default.

mbernardeau
  • 2,703
  • 1
  • 20
  • 19
43

It is possible to get this working in Visual Studio Code and have the Cmder terminal be integrated (not pop up).

To do so:

  1. Create an environment variable "CMDER_ROOT" pointing to your Cmder directory.

  2. In (PreferencesUser Settings) in Visual Studio Code, add the following settings:

    "terminal.integrated.shell.windows": "cmd.exe"

    "terminal.integrated.shellArgs.windows": ["/k", "%CMDER_ROOT%\\vendor\\init.bat"]

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
khernand
  • 531
  • 4
  • 5
  • 10
    This works on Windows 10, however I needed to change the slashes in the argument path:`["/k", "%CMDER_ROOT%\\vendor\\init.bat"]` – Lodybo Jul 05 '17 at 07:21
  • 3
    Worked great with @Lodybo's suggestion. Thanks! – Ben Force Jul 13 '17 at 23:35
  • 2
    Note I actually had to create a CMDER_ROOT environment variable. It didn't work to just replace the %CMDER_ROOT% in the config file with the path to init.bat – yoyoyoyosef Oct 02 '17 at 22:17
  • 3
    My only problem with this is, the command history is not saved when in integrated terminal. I cannot reselect the command a) in an external cmder.exe shell b) after restarting VS Code. Any ideas how to solve this? – ford04 Sep 21 '18 at 11:49
33

You can quickly accomplish that by just typing Ctrl + Shift + P and then type "default". It will show an option that says:

Terminal: Select Default Shell

It will then display all the terminals available to you.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
etp23
  • 331
  • 3
  • 3
  • 2
    Great Suggestion. Using this I easily swapped from cmd.exe to bash. Nice n simple. – Barry McDermid Nov 11 '20 at 13:46
  • 3
    There are two kinds of Terminals - Console and Integrate Console. The latter is used when debugging code. This answer does not affect it, so it does not really answer the OP question. – mark Nov 12 '20 at 00:03
9

From the official documentation:

Correctly configuring your shell on Windows is a matter of locating the right executable and updating the setting. Below is a list of common shell executables and their default locations.

There is also the convenience command Select Default Shell that can be accessed through the command palette which can detect and set this for you.

So you can open a command palette using Ctrl + Shift + P, use the command Select Default Shell, and then it displays all the available command line interfaces. Select whatever you want, and Visual Studio Code sets that as the default integrated terminal for you automatically.

If you want to set it manually find the location of executable of your CLI and open user settings of Visual Studio Code (Ctrl + `), and then set:

"terminal.integrated.shell.windows":"path/to/executable.exe"

Example for Git Bash on Windows 7:

"terminal.integrated.shell.windows":"C:\\Users\\stldev03\\AppData\\Local\\Programs\\Git\\bin\\bash.exe",
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
4

For the OP's terminal Cmder, there is an integration guide, also hinted in the Visual Studio Code documentation.

If you want to use Visual Studio Code tasks and encounter problems after switch to Cmder, there is an update to khernand's answer. Copy this into your settings.json file:

"terminal.integrated.shell.windows": "cmd.exe",

"terminal.integrated.env.windows": {
  "CMDER_ROOT": "[cmder_root]" // replace [cmder_root] with your cmder path
},
"terminal.integrated.shellArgs.windows": [
  "/k",
  "%CMDER_ROOT%\\vendor\\bin\\vscode_init.cmd" // <-- this is the relevant change
  // OLD: "%CMDER_ROOT%\\vendor\\init.bat"
],

The invoked file will open Cmder as an integrated terminal and switch to cmd for tasks. Have a look at the source here. So you can omit configuring a separate terminal in tasks.json to make tasks work.

Starting with VS Code 1.38, there is also "terminal.integrated.automationShell.windows" setting, which lets you set your terminal for tasks globally and avoids issues with Cmder.

"terminal.integrated.automationShell.windows": "cmd.exe"
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ford04
  • 66,267
  • 20
  • 199
  • 171
3

The method explained in the accepted answer has been deprecated, and now the new recommended way to configure your default shell is by creating a terminal profile in #terminal.integrated.profiles.windows# and setting its profile name as the default in #terminal.integrated.defaultProfile.windows#.

The old method will currently take priority over the new profiles settings, but that will change in the future.

See an example for PowerShell taken from the documentation:

{
  "terminal.integrated.profiles.windows": {
    "My PowerShell": {
      "path": "pwsh.exe",
      "args": ["-noexit", "-file", "${env:APPDATA}PowerShellmy-init-script.ps1"]
    }
  },
  "terminal.integrated.defaultProfile.windows": "My PowerShell"
}
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
CasualCoder3
  • 631
  • 7
  • 16
2

I was successful via SettingsTerminalIntegratedShell: Linux

From there, I edited the path of the shell to be /bin/zsh from the default /bin/bash

  • there are also options for OS X and Windows as well

Screen capture of Visual Studio Code settings view

@charlieParker - here's what I'm seeing for available commands in the Command Palette.

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
MCGRAW
  • 777
  • 14
  • 37
  • 2
    @CharlieParker i didn't see the option to edit the shell option, most of the available commands related to integrated terminal were actions in an already defined terminal - i added a screencap to my original answer - did you have an issue using the `preferences>settings` route i used? – MCGRAW Jun 10 '20 at 13:49
2

Change external terminal

Enter image description here

Windows Terminal, which has been mentioned by others, is an alternative of Alacritty, which is a terminal (emulator).

As stated in Visual Studio Code, Cmder is a shell, just like PowerShell or Bash.

Enter image description here

"terminal.integrated.profiles.windows": {
    "cmder": {
        //  "path": "F:\\cmder\\Cmder.exe",  // 这样会开external terminal
      "path": "C:\\WINDOWS\\System32\\cmd.exe",
      "args": ["/K", "F:\\cmder\\vendor\\bin\\vscode_init.cmd"]
    }
  },
"terminal.integrated.profiles.linux": { "zsh": { "path": "zsh" }, },
"terminal.integrated.defaultProfile.windows": "PowerShell",

enter image description here

The statement in Cmder's repository is misleading

Enter image description here

Different shells under a terminal:

Enter image description here

If you want to change the external terminal to the new Windows terminal, here's how.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Good Pen
  • 625
  • 6
  • 10
1

The below thing worked for me:

  1. Open Settings → this will open settings.json
  2. type terminal.integrated.windows.shell
  3. Click on {} at the top right corner. This will open an editor where this setting can be overridden.
  4. Set the value as terminal.integrated.windows.shell: C:\\Users\\<user_name>\\Softwares\\Git\\bin\\bash.exe
  5. Click Ctrl + S

Try to open a new terminal. It should open in a Bash editor in integrated mode.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
error404
  • 2,684
  • 2
  • 13
  • 21
1

This is working as of 02-Dec-2021.

In file settings.json:

 {
    "go.toolsManagement.autoUpdate":true,
    "terminal.integrated.profiles.windows":{
        "My Bash":{
            "path":"D:\\1. Installed_Software\\Git\\bin\\bash.exe"
        }
    },
    "terminal.integrated.defaultProfile.windows":"My Bash"
}

Reference: Terminal Basics

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
infiniteLearner
  • 3,555
  • 2
  • 23
  • 32