问题
Whenever I open the terminal in Visual Studio Code, I get a bash shell. I want to add CMD as a second shell. To do that, I went through the VS Code documentation and found this command:
CTRL+SHIFT+`
But it only opens a second bash shell. Is there a shortcut for opening CMD in the integrated terminal, rather than opening it in an external console?
回答1:
If you want to always open cmd, you can use the settings to configure that.
From the docs:
Correctly configuring your shell on Windows is a matter of locating the right executable and updating the setting. Below are a list of common shell executables and their default locations:
// Command Prompt
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"
// PowerShell
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
// Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\git-cmd.exe",
"terminal.integrated.shellArgs.windows": [
"--command=usr/bin/bash.exe",
"-l",
"-i"
]
// Bash on Ubuntu (on Windows)
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"
If you want to only sometimes open cmd, you may be able to simply open a new bash terminal and then run cmd
in it.
If you use both frequently, you may want to use an extension like this or this which allow you to pick your terminal when you launch it.
Keybindings:
[{
"key": "ctrl+shift+t",
"command": "shellLauncher.launch"
}]
Settings:
{
"shellLauncher.shells.windows": [
{
"shell": "bash",
"args": [],
"label": "bash"
}, {
"shell": "cmd",
"args": [],
"label": "cmd"
}
]
}
回答2:
- Press Ctrl + Shift + P to open the command palette.
- Type 'shell' in the searcher.
- Select 'Terminal: Select Default Shell'.
- Select 'Command Prompt'
- The next time you try to open the terminal you should see 'CMD' instead of 'PowerShell'.
回答3:
Add this on user setting Note: paste at top
{
"terminal.integrated.shell.windows": "cmd.exe"
// other settings...
}
回答4:
Just open the terminal and enter the link to your cmd application e.g C:\Windows\system32\cmd.exe
来源:https://stackoverflow.com/questions/46107955/open-cmd-in-the-visual-studio-code-terminal