启动Windows 终端(Windows Terminal)时,打开的默认 shell 是Windows PowerShell。但是,Windows 终端(Windows Terminal)支持许多具有命令行界面的应用程序,包括古老的命令提示符(Command Prompt)( CMD )。如果您想在Windows Terminal中切换到(Windows Terminal)CMD,或者如果您想让CMD成为(CMD)Windows Terminal的默认 shell,请执行以下操作:
注意:(NOTE:)本教程适用于Windows 10和Windows 11。在Windows 11中,Windows 终端( Windows Terminal)是命令行工具和 shell 的默认应用程序。如果您有 Windows 10,并且默认情况下未安装该应用程序,您可以从Microsoft Store(Microsoft Store)免费获取它。在此处阅读更多信息:如何获取 Windows 终端应用程序(How to get the Windows Terminal app)。
使用键盘更改Windows 终端中的外壳(Windows Terminal)
为了更改Windows Terminal中的 shell ,您首先需要启动该程序。默认情况下,终端(Terminal)以单个选项卡Windows PowerShell启动。但是,您可能会发现自己需要输入的命令是针对Command Prompt的,因此您需要切换 shell。更改为CMD的最直接方法是使用键盘快捷键。在终端(Terminal )窗口处于焦点时按Ctrl + Shift + 2这将打开一个带有命令提示符(Command Prompt)shell 的新选项卡。
在Windows 终端(Windows Terminal)中打开CMD的默认键盘快捷键(CMD)
您现在可以关闭第一个选项卡并开始使用CMD工作。要关闭第一个选项卡,请单击Windows PowerShell(Windows PowerShell )选项卡名称旁边的 X 按钮。
打开CMD后,您可以关闭其他选项卡
提示:(TIP:)如果你不是很懂技术,想了解更多关于 shell、终端和控制台的知识,我强烈推荐这篇文章:控制台、终端和 shell 有什么区别?(What's the difference between a console, a terminal, and a shell?)
使用应用程序菜单更改Windows 终端(Windows Terminal)中的外壳
打开Windows Terminal(opening Windows Terminal)后,单击或点击位于窗口顶部、当前选项卡旁边的看起来像 V 的按钮。这将打开终端(Terminal)菜单。在此菜单中,选择Command Prompt。
使用Windows 终端(Windows Terminal)菜单打开命令提示符选项卡(Command Prompt)
此操作使用命令提示符(Command Prompt)外壳打开一个新选项卡。现在通过按Windows PowerShell选项卡名称旁边的关闭选项卡(X) 按钮关闭第一个选项卡。(Close tab)
使用CMD或Windows PowerShell启动Windows 终端(Windows Terminal)
如果您愿意,可以直接使用所需的 shell启动Windows 终端。(Windows Terminal)为此,请按开始(Start)按钮,然后键入“Windows 终端”(“windows terminal”)以搜索应用程序。不要按Enter,而是在搜索结果列表的右窗格中查找所需的 shell。单击(Click)或点击其中一个选项,Windows 终端(Windows Terminal)将加载您选择的外壳。
使用搜索(Search)功能以您选择的外壳启动终端(Terminal)
提示:(TIP:)有关详细信息,请阅读如何在 Windows 11 中使用搜索(How to use Search in Windows 11)。
如何在Windows 终端中将(Windows Terminal)CMD设置为默认而不是PowerShell?
如果您使用命令提示符(Command Prompt)或除Windows PowerShell之外的任何其他 shell,您可以在(Windows PowerShell)终端(Terminal)中更改您的默认 shell 。这意味着每次启动Windows Terminal时都会自动打开所选的 shell 。
要在Windows Terminal中将(Windows Terminal)CMD而不是PowerShell设置为默认值,请按下(PowerShell)终端(Terminal)窗口顶部看起来像 V 的按钮。然后,选择设置(Settings)。
如何访问Windows 终端设置(Windows Terminal Settings)
在下一个屏幕上,确保在左侧窗格中选择了启动(Startup)(带有屏幕和箭头的图标)。如果左侧窗格不可见,请单击窗口左上角的汉堡按钮(打开导航)。(Open navigation)
现在转到右侧的默认配置文件,然后单击其下方的按钮。(Default Profile)
单击(Click)启动的(Startup)默认(Default)配置文件部分中的按钮
这将打开一个下拉列表,您可以在其中选择所需的外壳。单击(Click)命令提示符(Command Prompt),然后单击位于窗口右下角的保存按钮。(Save)
选择 CMD(Choose CMD)作为默认外壳,然后按保存
您可以对任何已安装的 shell 执行此操作。下次您启动Windows Terminal时,它将自动打开一个带有命令提示符(Command Prompt)(或您选择的 shell)的窗口。
您使用Windows PowerShell还是命令提示符(Command Prompt)?你更喜欢哪一个(Which one)?
自八十年代初以来,命令提示符(Command Prompt)一直存在。它仍然是我们最喜欢的命令行工具,但Windows PowerShell具有更多功能、更多兼容性和更多连接性,因此它显然是未来更好的选择。你更经常使用什么命令行工具?另外,您将两者中的哪一个设置为Windows Terminal的默认值?我们很乐意在评论部分听到您的想法。
How to switch between CMD and PowerShell in Windows Terminal
When starting Windows Terminal, the default shell that opens is Windows PowerShell. However, Windows Terminal supports many applications that have a command-line interface, including the venerable Command Prompt (CMD). If you want to switch to CMD in Windows Terminal, or if you want to make CMD the default shell for Windows Terminal, here’s how to do it:
NOTE: This tutorial applies both to Windows 10 and Windows 11. In Windows 11, Windows Terminal is the default application for command-line tools and shells. If you have Windows 10, and the application isn’t installed by default, you can get it for free from the Microsoft Store. Read more here: How to get the Windows Terminal app.
Changing the shell in Windows Terminal using the keyboard
In order to change the shell in Windows Terminal, you first need to launch the program. By default, Terminal starts with a single tab, Windows PowerShell. However, you may find yourself in a situation where the commands you need to input are for Command Prompt, so you need to switch shells. The most straightforward method to change to CMD is by using keyboard shortcuts. Press Ctrl + Shift + 2 while the Terminal window is in focus. This opens a new tab with the Command Prompt shell.
The default keyboard shortcut for opening CMD in Windows Terminal
You can now close the first tab and start working using CMD. To close the first tab, click on the X button next to the Windows PowerShell tab name.
After opening CMD, you can close the other tabs
TIP: If you are not very technical and want to know more about shells, terminals, and consoles, I highly recommend this article: What's the difference between a console, a terminal, and a shell?
Changing the shell in Windows Terminal using the application menu
After opening Windows Terminal, click or tap on the button that looks like a V located in the top part of the window, next to the current tab. This opens the Terminal menu. In this menu, choose Command Prompt.
Open a Command Prompt tab by using the Windows Terminal menu
This action opens a new tab with the Command Prompt shell. Now close the first tab by pressing the Close tab (X) button next to the Windows PowerShell tab name.
Starting Windows Terminal with CMD or Windows PowerShell
If you prefer, you can start Windows Terminal directly with the shell you need. To do this, press the Start button and then type “windows terminal” to search for the application. Do not press Enter, instead look for the desired shell in the right pane of the search results list. Click or tap on one of the options and Windows Terminal loads the shell you selected.
Use the Search feature to start Terminal with the shell of your choice
TIP: For more information, read How to use Search in Windows 11.
How do I set CMD as the default instead of PowerShell in Windows Terminal?
If you use Command Prompt or any other shell apart from Windows PowerShell, you can change your default shell in Terminal. This means that the chosen shell opens automatically each time you start Windows Terminal.
To set CMD as default instead of PowerShell in Windows Terminal, press the button that looks like a V in the top part of the Terminal window. Then, choose Settings.
How to access the Windows Terminal Settings
On the next screen, make sure that Startup (the icon with a screen and an arrow) is selected in the left pane. If the left pane isn’t visible, click on the hamburger button (Open navigation) in the upper left corner of the window.
Now go to Default Profile on the right side and click on the button below it.
Click on the button in the Default profile section of Startup
This opens a drop-down list where you can select the desired shell. Click on Command Prompt, then click on the Save button located in the lower right corner of the window.
Choose CMD as the default shell and press Save
You can do this for any of the installed shells. The next time you start Windows Terminal, it will automatically open a window with Command Prompt (or the shell that you selected).
Do you use Windows PowerShell or Command Prompt? Which one do you prefer?
Command Prompt has been around since the early eighties. It is still our favorite command-line tool, but Windows PowerShell has more functionality, more compatibility, and more connectivity, so it’s clearly a better choice for the future. What command-line tool do you use more often? Also, which of the two did you set as the default for Windows Terminal? We’d love to hear your thoughts in the comment section.