I would like to switch from powershell.exe to cmd.exe in the terminal but i’m not sure how to do so. Provided screenshot for clarification.
melpomene
83.2k8 gold badges81 silver badges145 bronze badges
asked Mar 10, 2017 at 22:58
1
- Press
Ctrl
+Shift
+P
to show all commands. - Type
profile
in the displayed text box to filter the list. - Select
Terminal: Select Default Profile
. - You will be prompted to
Select your preferred terminal shell, you can change this later in your settings or follow the same process as we do now
- Select
Command Prompt
(cmd.exe) - Click the Delete Icon in the shell pane to remove the existing terminal.
- Press
Ctrl
+`
(or View > Terminal in menu) to open a new terminal pane.
answered May 3, 2017 at 5:29
4
Add this user settings to your File — Prefernces — User Settings
// Place your settings in this file to overwrite the default settings
{
"terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe",
}
answered Mar 10, 2017 at 23:27
AravindAravind
39.7k16 gold badges89 silver badges109 bronze badges
1
2021 Update:
Hit Ctrl+Shift+P
Type/Paste : Terminal: Select Default Profile
Select the command prompt from the drop down list.
Thanks!
answered Jun 6, 2021 at 15:24
Abhishek GautamAbhishek Gautam
1,5492 gold badges19 silver badges29 bronze badges
I found two different ways to switch from powershell to command prompt in VSCode.
Very simple steps i found my self as below:
First one is very simple way:
- Press
Ctrl
+`
(or View > Terminal in menu) to open a
new terminal pane. - Click terminal selection dropdown and click ‘Select Default Shell’.
- Choose terminal type
Command Prompt
orPowerShell
- Now Delete current opened terminal or open new terminal.
Now, Command Prompt will be your default shell in VSCode.
Second one is also simple and handy for all devs.
- Press
Ctrl
+Shift
+P
to show all commands. - Type
shell
in the displayed text box to filter the list. - Select
Terminal: Select Default Shell
. - You will be prompted to
Select your preferred terminal shell, you can change this later in your settings or follow the same process as we do now
- Select
Command Prompt
(cmd.exe) - Click the Delete Icon in the shell pane to remove the existing terminal.
- Press
Ctrl
+`
(or View > Terminal in menu) to open a new terminal pane.
answered Apr 9, 2020 at 10:57
BhavinD.BhavinD.
4255 silver badges18 bronze badges
1
open settings (ctrl+comma)
find terminal.integrated.shell.windows
replace its value with C:\Windows\System32\cmd.exe
answered Dec 5, 2017 at 9:23
I also faced this problem that when I clicked on terminal. It was showing Powershell but not Command Prompt, so I did the following steps to get Command Prompt in Visual Studio:
- View -> Command palette -> Toggle Integrated Terminal
- Open terminal by shortcut ctrl+`
or View -> terminal - Write the command as
cmd.exe
and run
Yksisarvinen
16.4k2 gold badges22 silver badges49 bronze badges
answered Dec 9, 2018 at 19:19
In the current terminal ,simply type cmd and enter. And you are done.
answered Dec 8, 2020 at 7:52
From Visual Studio if you have powershell set as your default integrated terminal, after you call it with Ctrl-` (control backtick) — that toggles from the terminal to your files panel and back. Call the terminal, It will show as 1: pwsh in the dropdown box. From the powershell command line type bash and enter. You have your bash prompt $. In the dropdown you now see 1: bash.
You can type cmd from either the ps C: or the $ bash prompt and open the windows command prompt. C:> and exit to exit them.
You can open up multiple terminals. Say powershell (pwsh) is your default one. A new terminal will show as 2: pwsh which you can change to a cmd one. The same if you open a third. Change it to bash. You now have 3 terminals 1: pwsh, 2: cmd, and 3: bash. You can select whichever one you want to work with from the dropdown. You can of course exit any of them.
No doubt you’ve seen that when you are running node.js, the terminal becomes node.
answered Jan 1, 2021 at 19:49
user258081user258081
1711 silver badge8 bronze badges
Terminal profiles are platform-specific shell configurations comprised of an executable path, arguments, and other customizations. By default several profiles are automatically detected which can be customized or added to.
Example profile:
{
"terminal.integrated.profiles.windows": {
"Custom Init": {
"path": "pwsh.exe",
"args": [
"-noexit",
"-file",
"${env:APPDATA}\PowerShell\custom-init.ps1"
]
}
},
"terminal.integrated.defaultProfile.windows": "Custom Init"
}
You can use variables in terminal profiles as shown in the example above with the APPDATA
environment variable. There is a list of available variables in the Variables Reference topic.
Configure your default profile by running the Terminal: Select Default Profile command, which is also accessible via the new terminal dropdown.
The default terminal profile shell defaults to $SHELL
on Linux and macOS and PowerShell on Windows. VS Code will automatically detect most standard shells that can then be configured as the default.
Configuring profiles
To create a new profile, run the Terminal: Select Default Profile command and activate the configure button on the right side of the shell to base it on. This will add a new entry to your settings that can be tweaked manually in your settings.json
file.
Profiles can be created using either a path
or a source
, as well as a set of optional arguments. A source
is available only on Windows and can be used to let VS Code detect the install of either PowerShell
or Git Bash
. Alternatively, a path
pointing directly to the shell executable can be used. Here are some example profile configurations:
{
"terminal.integrated.profiles.windows": {
"PowerShell -NoProfile": {
"source": "PowerShell",
"args": ["-NoProfile"]
}
},
"terminal.integrated.profiles.linux": {
"zsh (login)": {
"path": "zsh",
"args": ["-l"]
}
}
}
Other arguments supported in profiles include:
overrideName
: A boolean indicating whether or not to replace the dynamic terminal title that detects what program is running with the static profile name.env
: A map defining environment variables and their values, set the variable tonull
to delete it from the environment. This can be configured for all profiles using theterminal.integrated.env.<platform>
setting.icon
: An icon ID to use for the profile.color
: A theme color ID to style the icon.
Tip: Path, args, and env all support resolving variables
The default profile can be defined manually with the terminal.integrated.defaultProfile.*
settings. This should be set to the name of an existing profile:
{
"terminal.integrated.profiles.windows": {
"my-pwsh": {
"source": "PowerShell",
"args": ["-NoProfile"]
}
},
"terminal.integrated.defaultProfile.windows": "my-pwsh"
}
Tip: The integrated terminal shell is running with the permissions of VS Code. If you need to run a shell command with elevated (administrator) or different permissions, use platform utilities such as
runas.exe
within a terminal.
Removing built-in profiles
To remove a built-in profile and prevent it from showing up in the new terminal dropdown, set the name of the profile to null
. For example, to remove the Git Bash
profile on Windows, use this setting:
{
"terminal.integrated.profiles.windows": {
"Git Bash": null
}
}
Configuring the task/debug profile
By default, the task/debug features will use the default profile. This may not be ideal if your default has a heavy PowerShell startup script or a non-POSIX compliant shell for example. To configure a profile to be used only in the debug/tasks features, use the terminal.integrated.automationProfile.<platform>
setting:
{
"terminal.integrated.defaultProfile.osx": "fish",
// Use a fully POSIX-compatible shell and avoid running a complex ~/.config/fish/config.fish
// for tasks and debug
"terminal.integrated.automationProfile.osx": {
"path": "/bin/sh"
}
}
Unsafe profile detection
Certain shells are installed in unsafe paths by default, like a path that could be written to by another user on a Windows environment. VS Code will still detect these but not expose them as a proper profile until they have been explicitly configured via the Terminal: Select Default Profile command. When configuring an unsafe profile, there will be a warning before it’s added:
Cmder
Cmder itself is a terminal, but you can use the Cmder shell in VS Code with the following profile:
{
"terminal.integrated.profiles.windows": {
"cmder": {
"path": "C:\WINDOWS\System32\cmd.exe",
"args": ["/K", "C:\cmder\vendor\bin\vscode_init.cmd"]
}
},
"terminal.integrated.defaultProfile.windows": "cmder"
}
This profile should be picked up automatically when the CMDER_ROOT
environment variable is set. It will also be detected as an unsafe profile if installed at C:cmder
. You may refer to Cmder’s wiki for more information.
Cygwin
Cygwin itself is a terminal, but you can use the Cygwin shell in VS Code with the following profile:
{
"terminal.integrated.profiles.windows": {
"Cygwin": {
"path": "C:\cygwin64\bin\bash.exe",
"args": ["--login"]
}
},
"terminal.integrated.defaultProfile.windows": "Cygwin"
}
This profile should be detected automatically as an unsafe profile when installed at the default paths C:cygwin
or C:cygwin64
.
Git Bash
A limitation of Git Bash when VS Code uses bash.exe (the shell) as opposed to git-bash.exe (the terminal) is that history will not be retained across shell sessions. You can work around this by adding the following to your ~/.bashrc
or ~/.bash_profile
files:
export PROMPT_COMMAND='history -a'
This will cause the shell to call history -a
whenever the prompt is printed which flushes the session’s current session commands to the backing history file.
MSYS2
MSYS2’s bash shell can be configured with the following profile:
{
"terminal.integrated.profiles.windows": {
"bash (MSYS2)": {
"path": "C:\msys64\usr\bin\bash.exe",
"args": ["--login", "-i"]
}
}
}
This profile should be detected automatically as an unsafe profile when installed at the default path C:\msys64
.
Windows PowerShell
When PowerShell 6+ is installed, Windows PowerShell is not included in the profiles list by default. To add Windows PowerShell as a profile, choose the Select Default Profile option in the new terminal dropdown and select the Windows PowerShell item. This will configure the profile and set it as your default.
WSL
When running VS Code on your local machine, Windows Subsystem for Linux shells should be automatically detected. Depending on your setup, this may be a nuisance if you have a lot of distros installed. For finer control over the WSL profiles the automatic detection can be disabled with the terminal.integrated.useWslProfiles
setting, then here’s an example of how to manually configure a WSL shell:
{
"terminal.integrated.profiles.windows": {
"Debian (WSL)": {
"path": "C:\WINDOWS\System32\wsl.exe",
"args": [
"-d",
"Debian"
]
}
}
}
Common questions
Why are there duplicate paths in the terminal’s $PATH
environment variable and/or why are they reversed on macOS?
This can happen on macOS because of how the terminal launches using VS Code’s environment. When VS Code launches for the first time, to source your «development environment,» it launches your configured shell as a login shell, which runs your ~/.profile
/~/.bash_profile
/~/.zprofile
scripts. Now when the terminal launches, it also runs as a login shell, which will put the standard paths to the front (for example, /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
) and reinitialize your shell environment.
To get a better understanding, you can simulate what is happening by launching an inner login shell within your operating system’s built-in terminal:
# Add /test to the beginning of $PATH
export PATH=/test:$PATH
# Echo $PATH, /test should be at the beginning
echo $PATH
# Run bash as a login shell
bash -l
# Echo $PATH, the values should be jumbled
echo $PATH
Unfortunately, unlike in Linux, standalone macOS terminals all run as login shells by default, since macOS does not run a login shell when the user logs into the system. This encourages «bad behavior,» like initializing aliases in your profile script when they should live in your rc
script as that runs on non-login shells.
There are two direct fixes for this. The first is to set "terminal.integrated.inheritEnv": false
, which will strip most environment variables from the terminal’s environment, except for some important ones (like HOME
, SHELL
, TMPDIR
, etc.).
The other fix is to no longer run a login shell in the terminal by creating a terminal profile and setting its args
to []
. If you go with this fix, you will want to make sure any aliases in your profile scripts are moved over to your ~/.bashrc
/~/.zshrc
file since aliases only apply to the shell they’re set in.
2/2/2023
I would like to switch from powershell.exe to cmd.exe in the terminal but i’m not sure how to do so. Provided screenshot for clarification.
melpomene
83.2k8 gold badges81 silver badges145 bronze badges
asked Mar 10, 2017 at 22:58
1
- Press
Ctrl
+Shift
+P
to show all commands. - Type
profile
in the displayed text box to filter the list. - Select
Terminal: Select Default Profile
. - You will be prompted to
Select your preferred terminal shell, you can change this later in your settings or follow the same process as we do now
- Select
Command Prompt
(cmd.exe) - Click the Delete Icon in the shell pane to remove the existing terminal.
- Press
Ctrl
+`
(or View > Terminal in menu) to open a new terminal pane.
answered May 3, 2017 at 5:29
4
Add this user settings to your File — Prefernces — User Settings
// Place your settings in this file to overwrite the default settings
{
"terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe",
}
answered Mar 10, 2017 at 23:27
AravindAravind
39.7k16 gold badges89 silver badges109 bronze badges
1
2021 Update:
Hit Ctrl+Shift+P
Type/Paste : Terminal: Select Default Profile
Select the command prompt from the drop down list.
Thanks!
answered Jun 6, 2021 at 15:24
Abhishek GautamAbhishek Gautam
1,5492 gold badges19 silver badges29 bronze badges
I found two different ways to switch from powershell to command prompt in VSCode.
Very simple steps i found my self as below:
First one is very simple way:
- Press
Ctrl
+`
(or View > Terminal in menu) to open a
new terminal pane. - Click terminal selection dropdown and click ‘Select Default Shell’.
- Choose terminal type
Command Prompt
orPowerShell
- Now Delete current opened terminal or open new terminal.
Now, Command Prompt will be your default shell in VSCode.
Second one is also simple and handy for all devs.
- Press
Ctrl
+Shift
+P
to show all commands. - Type
shell
in the displayed text box to filter the list. - Select
Terminal: Select Default Shell
. - You will be prompted to
Select your preferred terminal shell, you can change this later in your settings or follow the same process as we do now
- Select
Command Prompt
(cmd.exe) - Click the Delete Icon in the shell pane to remove the existing terminal.
- Press
Ctrl
+`
(or View > Terminal in menu) to open a new terminal pane.
answered Apr 9, 2020 at 10:57
BhavinD.BhavinD.
4255 silver badges18 bronze badges
1
open settings (ctrl+comma)
find terminal.integrated.shell.windows
replace its value with C:\Windows\System32\cmd.exe
answered Dec 5, 2017 at 9:23
I also faced this problem that when I clicked on terminal. It was showing Powershell but not Command Prompt, so I did the following steps to get Command Prompt in Visual Studio:
- View -> Command palette -> Toggle Integrated Terminal
- Open terminal by shortcut ctrl+`
or View -> terminal - Write the command as
cmd.exe
and run
Yksisarvinen
16.4k2 gold badges22 silver badges49 bronze badges
answered Dec 9, 2018 at 19:19
In the current terminal ,simply type cmd and enter. And you are done.
answered Dec 8, 2020 at 7:52
From Visual Studio if you have powershell set as your default integrated terminal, after you call it with Ctrl-` (control backtick) — that toggles from the terminal to your files panel and back. Call the terminal, It will show as 1: pwsh in the dropdown box. From the powershell command line type bash and enter. You have your bash prompt $. In the dropdown you now see 1: bash.
You can type cmd from either the ps C: or the $ bash prompt and open the windows command prompt. C:> and exit to exit them.
You can open up multiple terminals. Say powershell (pwsh) is your default one. A new terminal will show as 2: pwsh which you can change to a cmd one. The same if you open a third. Change it to bash. You now have 3 terminals 1: pwsh, 2: cmd, and 3: bash. You can select whichever one you want to work with from the dropdown. You can of course exit any of them.
No doubt you’ve seen that when you are running node.js, the terminal becomes node.
answered Jan 1, 2021 at 19:49
user258081user258081
1711 silver badge8 bronze badges
I would like to switch from powershell.exe to cmd.exe in the terminal but i’m not sure how to do so. Provided screenshot for clarification.
melpomene
83.2k8 gold badges81 silver badges145 bronze badges
asked Mar 10, 2017 at 22:58
1
- Press
Ctrl
+Shift
+P
to show all commands. - Type
profile
in the displayed text box to filter the list. - Select
Terminal: Select Default Profile
. - You will be prompted to
Select your preferred terminal shell, you can change this later in your settings or follow the same process as we do now
- Select
Command Prompt
(cmd.exe) - Click the Delete Icon in the shell pane to remove the existing terminal.
- Press
Ctrl
+`
(or View > Terminal in menu) to open a new terminal pane.
answered May 3, 2017 at 5:29
4
Add this user settings to your File — Prefernces — User Settings
// Place your settings in this file to overwrite the default settings
{
"terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe",
}
answered Mar 10, 2017 at 23:27
AravindAravind
39.7k16 gold badges89 silver badges109 bronze badges
1
2021 Update:
Hit Ctrl+Shift+P
Type/Paste : Terminal: Select Default Profile
Select the command prompt from the drop down list.
Thanks!
answered Jun 6, 2021 at 15:24
Abhishek GautamAbhishek Gautam
1,5492 gold badges19 silver badges29 bronze badges
I found two different ways to switch from powershell to command prompt in VSCode.
Very simple steps i found my self as below:
First one is very simple way:
- Press
Ctrl
+`
(or View > Terminal in menu) to open a
new terminal pane. - Click terminal selection dropdown and click ‘Select Default Shell’.
- Choose terminal type
Command Prompt
orPowerShell
- Now Delete current opened terminal or open new terminal.
Now, Command Prompt will be your default shell in VSCode.
Second one is also simple and handy for all devs.
- Press
Ctrl
+Shift
+P
to show all commands. - Type
shell
in the displayed text box to filter the list. - Select
Terminal: Select Default Shell
. - You will be prompted to
Select your preferred terminal shell, you can change this later in your settings or follow the same process as we do now
- Select
Command Prompt
(cmd.exe) - Click the Delete Icon in the shell pane to remove the existing terminal.
- Press
Ctrl
+`
(or View > Terminal in menu) to open a new terminal pane.
answered Apr 9, 2020 at 10:57
BhavinD.BhavinD.
4255 silver badges18 bronze badges
1
open settings (ctrl+comma)
find terminal.integrated.shell.windows
replace its value with C:\Windows\System32\cmd.exe
answered Dec 5, 2017 at 9:23
I also faced this problem that when I clicked on terminal. It was showing Powershell but not Command Prompt, so I did the following steps to get Command Prompt in Visual Studio:
- View -> Command palette -> Toggle Integrated Terminal
- Open terminal by shortcut ctrl+`
or View -> terminal - Write the command as
cmd.exe
and run
Yksisarvinen
16.4k2 gold badges22 silver badges49 bronze badges
answered Dec 9, 2018 at 19:19
In the current terminal ,simply type cmd and enter. And you are done.
answered Dec 8, 2020 at 7:52
From Visual Studio if you have powershell set as your default integrated terminal, after you call it with Ctrl-` (control backtick) — that toggles from the terminal to your files panel and back. Call the terminal, It will show as 1: pwsh in the dropdown box. From the powershell command line type bash and enter. You have your bash prompt $. In the dropdown you now see 1: bash.
You can type cmd from either the ps C: or the $ bash prompt and open the windows command prompt. C:> and exit to exit them.
You can open up multiple terminals. Say powershell (pwsh) is your default one. A new terminal will show as 2: pwsh which you can change to a cmd one. The same if you open a third. Change it to bash. You now have 3 terminals 1: pwsh, 2: cmd, and 3: bash. You can select whichever one you want to work with from the dropdown. You can of course exit any of them.
No doubt you’ve seen that when you are running node.js, the terminal becomes node.
answered Jan 1, 2021 at 19:49
user258081user258081
1711 silver badge8 bronze badges