Windows Terminal是 Microsoft 对命令行和(Windows Terminal)Windows PowerShell的组合替代品,让您在Windows上运行比图形用户界面更强大的管理命令和工具。
新的Windows 终端(Windows Terminal)不是从一种工具切换到另一种工具,而是将这些工具结合在一起。您可以运行Windows bash 脚本、连接到Azure虚拟机并打开适用于 Linux(Windows Subsystem for Linux)终端的 Windows 子系统——所有这些都在一个窗口中完成。
安装新的 Windows 终端(Installing The New Windows Terminal)
新的Windows 终端(Windows Terminal)应用程序仍在积极开发中。微软(Microsoft)没有在内部进行测试,而是在Microsoft Store中提供了一个“预览”版本作为下载。
它支持选项卡式窗口、改进的文本显示和高级配置,让您可以为各种应用程序自定义个人用户配置文件。它也是开源的,这意味着您可以自己探索并为项目做出贡献。
您也可以自己从Github 存储库(Github repository)下载和编译最新版本。但是,为了获得最佳稳定性,最好使用 Microsoft 的预构建版本。它仍在测试中,因此您在使用过程中可能仍会遇到一些错误。
- 首先,前往Microsoft Store网站上的Windows 终端(预览版)列表(Windows Terminal (Preview) listing),然后单击获取(Get)。如果您使用的是Chrome ,请通过单击弹出对话框中的打开 Microsoft Store(Open Microsoft Store)按钮来允许它打开Microsoft Store。或者,直接在Microsoft Store应用中搜索Windows Terminal 。
- 在Microsoft Store(Microsoft Store)应用程序中按照与上述相同的说明进行操作。单击(Click) 获取(Get)将应用程序链接到您的Microsoft帐户,然后单击安装(Install)开始安装。
- 安装后,单击启动(Launch),或从Windows 开始(Windows Start)菜单访问它。
使用新的 Windows 终端(Using The New Windows Terminal)
新 Windows 终端(New Windows Terminal)应用程序的界面非常简单。默认情况下,它看起来很像典型的Windows PowerShell窗口。
这是因为默认情况下,它打开的第一个选项卡将是PowerShell终端。您可以使用 Windows PowerShell(use Windows PowerShell)执行系统管理任务,另外还有一个优势是可以在单个窗口中打开多个PowerShell选项卡。(PowerShell)
这是New Windows Terminal的真正好处,它允许您在同一窗口内的不同应用程序和终端 shell 之间切换。您可以在第二个Windows 终端(Windows Terminal)选项卡中打开一个老式命令行,以及一个Azure Cloud Shell来远程管理您的Microsoft Azure虚拟机。
如果您安装了适用于Linux发行版的(Linux)Windows 子系统(Windows Subsystem),这些也会显示出来,让您可以轻松访问Windows中的(Windows)Linux终端。
- 要打开新的PowerShell窗口,请单击最后一个选项卡右侧的加号按钮(plus button)。要打开其他类型的选项卡,请单击向下箭头按钮(downward arrow button)并从可用选项列表中选择一个。
准备配置 Windows 终端(Preparing To Configure Windows Terminal)
新的Windows 终端(Windows Terminal)非常可定制。您可以更改其外观,包括修改背景、文本颜色和字体。Microsoft还包括预设主题供您切换,但您可以使用JSON配置文件创建自己的主题。
您可以为Windows 终端(Windows Terminal)支持的每种终端和应用程序类型创建自定义设置。
Notepad++后,您需要配置Windows以使用它打开JSON文件。
- 前往您的默认Windows 终端(Windows Terminal)设置文件夹。打开Windows 文件资源管理器(Windows File Explorer),然后键入%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState。该文件夹应该有一个profiles.json文件。右键单击该文件,然后单击打开方式(Open with)。
- 在应用程序选择菜单中,单击更多应用程序(More apps),然后单击在此 PC 上查找另一个应用程序(Look for another app on this PC)。
- 在应用程序选择对话框中,前往Notepad++的默认安装位置。对于大多数用户来说,这可以在C:\Program Files (x86)\Notepad++中找到。选择Notepad++.exe 然后单击Open。
在此之后,profiles.json配置文件将始终在Notepad++中打开。您可以从这里开始自定义您的 Windows终端(Terminal)体验。
Windows 终端配置文件(The Windows Terminal Configuration File)
JSON文件有点复杂,但profiles.json文件很容易处理。现在将Notepad++配置为自动打开JSON文件,您可以随时在Windows 终端(Windows Terminal)中访问您的设置文件。
- 要打开设置文件,请单击Windows 终端(Windows Terminal)选项卡旁边的向下箭头按钮(downward arrow button ),然后单击设置(Settings)。这将打开profiles.json文件供您编辑。
JSON文件具有单独的“配置文件”部分,允许您编辑每种类型的应用程序和终端外壳的配置文件。例如,如果您想更改Windows 终端(Windows Terminal)在PowerShell应用程序中的外观,请查找PowerShell部分。使用“名称”(“name”)或“命令行”(“commandline”)行来查找每个配置文件。
添加自定义 Windows 终端背景(Adding Custom Windows Terminal Backgrounds)
如果您想添加自定义背景,请先将合适的PNG、JPEG或GIF文件复制到您的设置文件夹。
- 打开您的设置文件,并在每个配置文件部分下,在“命令行”(“commandline”)行下方添加以下内容:
“backgroundImage” : “ms-appdata:///local/yourimagefile.jpg”,
“背景图像不透明度”:0.7,(“backgroundImageOpacity” : 0.7,)
“backgroundImageStrechMode”:“填充”,(“backgroundImageStrechMode” : “fill”,)
- 将“yourimagefile.jpg”替换为图像的文件名,然后按Ctrl + S保存。您还可以根据自己的要求自定义“backgroundImageOpacity”和“backgroundImageStretchMode”设置。
- 保存后,您的Windows 终端(Windows Terminal)背景将立即更改以匹配您指定的背景图像。
更改新的 Windows 终端配色方案(Changing The New Windows Terminal Color Scheme)
为了让您能够快速更改新的Windows 终端(Windows Terminal)配色方案,您可以使用五个默认主题之一。更改此设置的方法类似于上面列出的更改背景的方法。
- 首先(Start)打开您的设置文件,然后在每个配置文件部分下,添加以下行:
“colorScheme”:“坎贝尔”,(“colorScheme” : “Campbell”,)
- 按Ctrl + S保存,Windows 终端(Windows Terminal)将立即更新以显示新方案。
这会将您选择的应用配置文件的配色方案更改为“Campbell”配色方案,该方案源自Microsoft Console Colortool。您可以将其更改为“One Half Dark”、“One Half Light”、“Solarized Dark”或“Solarized Light”作为替代方案。
有关Windows 终端(Windows Terminal)配置文件的更多信息,请查看Github存储库中提供的文档文件(documentation file)。
How To Install & Use The New Windows 10 Terminal
Wіndows Terminal is Microsoft’s combined replacemеnt for the command linе and Windows PowerЅhell, letting you run more powerful administrativе commаnds and tools on Wіndows than you’d otherwise able to use from a graphical user interface.
Rather than switch from one tool to another, the new Windows Terminal brings these tools together. You can run Windows bash scripts, connect to Azure virtual machines, and open a Windows Subsystem for Linux terminal—all within a single window.
Installing The New Windows Terminal
The new Windows Terminal app is still in active development. Rather than test it internally, Microsoft has made a “preview” release available as a download in the Microsoft Store.
It brings support for tabbed windows, improved text display, and advanced configuration, letting you customize individual user profiles for your various apps. It’s also open-source, meaning you can poke around and contribute to the project yourself.
You can also download and compile the latest release yourself from the Github repository. For the best chance of stability, however, it’s best to use Microsoft’s pre-built version. It’s still in testing, so you may still experience some bugs during use.
- To start, head to the Windows Terminal (Preview) listing on the Microsoft Store website, then click Get. If you’re using Chrome, allow it to open the Microsoft Store by clicking the Open Microsoft Store button in the pop-up dialog box. Alternatively, search for Windows Terminal in the Microsoft Store app directly.
- Follow the same instructions as above in the Microsoft Store app. Click Get to link the app to your Microsoft account, then Install to begin the installation.
- Once installed, click Launch, or access it from your Windows Start menu.
Using The New Windows Terminal
The interface to the New Windows Terminal app is incredibly simple. By default, it’ll look a lot like a typical Windows PowerShell window.
That’s because, by default, the first tab it opens will be a PowerShell terminal. You can use Windows PowerShell to perform system administration tasks, with the added advantage that you can open multiple PowerShell tabs in a single window.
This is the real benefit of New Windows Terminal, allowing you to switch between different apps and terminal shells within the same window. You can open an old-school command line in a second Windows Terminal tab, as well as an Azure Cloud Shell to remotely manage your Microsoft Azure virtual machines.
If you have a Windows Subsystem for Linux distributions installed, these will be displayed, too, giving you easy access to a Linux terminal in Windows.
- To open a new PowerShell window, click the plus button to the right of your last tab. To open other types of tabs, click the downward arrow button and select one from the list of available options.
Preparing To Configure Windows Terminal
The new Windows Terminal is extremely customizable. You can change its appearance, including modifying the background, text color and font. Microsoft also includes pre-set themes for you to switch to, but you can create your own using the JSON configuration file.
You can create custom settings for each of the types of terminals and apps that the Windows Terminal supports.
- You can edit a JSON file using Notepad, but it’s best to use a third-party Windows app called Notepad++, which offers better formatting for JSON files, making it easier to edit. Download and install Notepad++ before you begin.
With Notepad++ installed, you’ll need to configure Windows to open JSON files using it.
- Head to your default Windows Terminal settings folder. Open up Windows File Explorer, then type %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState. The folder should have a profiles.json file. Right-click the file, then click Open with.
- In the app selection menu, click More apps, then click Look for another app on this PC.
- In the app selection dialog box, head to the default installation location for Notepad++. For most users, this can be found at C:\Program Files (x86)\Notepad++. Select Notepad++.exe then click Open.
After this, the profiles.json configuration file will always open in Notepad++. You can begin customizing your Windows Terminal experience from here.
The Windows Terminal Configuration File
JSON files are a little complicated, but the profiles.json file is pretty easy to work through. With Notepad++ now configured to automatically open JSON files, you can access your settings file within Windows Terminal at any point.
- To open the settings file, click the downward arrow button next to your Windows Terminal tabs, then click Settings. This will open the profiles.json file for you to edit.
The JSON file has separate “profiles” sections that allow you to edit the profiles for each type of app and terminal shell. If you wanted to change how Windows Terminal looks in a PowerShell app, for instance, look for the PowerShell section. Use the “name” or “commandline” lines to find each profile.
Adding Custom Windows Terminal Backgrounds
If you want to add a custom background, copy a suitable PNG, JPEG or GIF file to your settings folder first.
- Open your settings file and, under each profile section, add the following underneath the “commandline” line:
“backgroundImage” : “ms-appdata:///local/yourimagefile.jpg”,
“backgroundImageOpacity” : 0.7,
“backgroundImageStrechMode” : “fill”,
- Replace “yourimagefile.jpg” with the filename for your image, and press Ctrl + S to save afterward. You can also customize the “backgroundImageOpacity” and “backgroundImageStretchMode” settings to your own requirements.
- Once saved, your Windows Terminal background will immediately change to match the background image you’ve specified.
Changing The New Windows Terminal Color Scheme
To allow you to quickly change your new Windows Terminal color scheme, you can use one of five default themes. The method for changing this is similar to the method listed above to change your background.
- Start by opening your settings file and, under each profile section, add the following line:
“colorScheme” : “Campbell”,
- Press Ctrl + S to save, and Windows Terminal will immediately update to show the new scheme.
This will change your color scheme for your chosen app profile to the “Campbell” color scheme, a scheme originating from Microsoft Console Colortool. You can change this to “One Half Dark”, “One Half Light”, “Solarized Dark” or “Solarized Light” as an alternative.
For more information on the Windows Terminal configuration file, take a look at the documentation file available at the Github repository.