如果你是一个Windows用户,并且喜欢开发软件,或者只是对你的电脑在互联网、Facebook和Gmail之外能做什么感兴趣,那么这篇文章就是为你准备的。一段时间以来,Windows操作系统一直受到作为终端的cmd提示符非常过时的影响。这导致人们安装第三方工具,如GIT bash、Hyper.js、Commander和其他工具,以获得功能更丰富的命令行体验。微软已经听到了你对更好的终端体验的呼声,你现在可以从微软在线商店下载新Windows终端。
这个新终端既强大又开源,因为你可以在它的Github资源库中看到源代码。微软新终端有许多新功能,其中之一是标签!因此,如果你习惯于在你的电脑上打开几十个标签,那么你就会发现,你的电脑上有很多标签。因此,如果你习惯于在你的电脑上打开几十个标签,就像任何好的注意力缺陷的技术专家一样,那么你会为终端中的标签感到兴奋。显然,它也有一个GPU加速渲染引擎,以及Unicode和UTF-8字符支持。对我来说,这听起来很酷。
安装新的微软终端
有了这些介绍,你应该为Windows上这个令人敬畏的新命令行界面体验感到兴奋。为了亲自试驾这个新软件,你需要确保你满足安装和运行这个新工具的要求。
- 你的操作系统版本应该是Windows 10 v18362.0或更高。
- 架构应该是x64、ARM64或x86
如果你满足了操作系统和架构的要求,并安装了新的终端,你会看到这个漂亮的布局和一个新的Powershell提示,让你开始。
定制新终端
这个新终端为你提供了许多自定义的选项。你可以改变诸如背景颜色、添加背景图片、设置配色方案等等。如果我们点击设置下拉菜单。
A profiles.json
文件打开时有这些内容。
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles":
[
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
// Make changes here to the cmd.exe profile
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "cmd",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
],
// Add custom color schemes to this array
"schemes": [],
// Add any keybinding overrides to this array.
// To unbind a default keybinding, set the command to "unbound"
"keybindings": []
}
这些设置被分成两个文件:一个是硬编码的
defaults.json
,和profiles.json
,它包含用户设置。用户应该只关心profiles.json的内容,其中包含他们的定制。defaults.json文件只是作为默认设置的一个参考。
自定义背景颜色
但我只是想改变终端的背景颜色,你在想。我怎么能这样做呢?你很幸运。该 profiles.json
文件有一个名为 "方案"的部分。在那里,你可以添加自定义的颜色方案。考虑到我们想把背景颜色改成Ubuntu终端的紫色色调。这里强调的改动将给我们带来这种效果。
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles": [
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"colorScheme": "UbuntuPurple"
},
{
// Make changes here to the cmd.exe profile
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "cmd",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
],
// Add custom color schemes to this array
"schemes": [
{
"name": "UbuntuPurple",
"background": "#2C001E"
}
],
// Add any keybinding overrides to this array.
// To unbind a default keybinding, set the command to "unbound"
"keybindings": []
}
随着新添加到 profiles.json
,你可以看到新的颜色马上就生效了不需要重新启动终端。只要用有效的配置选项更新JSON,瞧,你就可以开始了。
如果你想尝试,有几个默认的颜色方案。下面是如何做到这一点的。
一半深色
"profiles": [
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"colorScheme": "One Half Dark"
}
一半光
"profiles": [
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"colorScheme": "One Half Light"
}
晒黑
"profiles": [
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"colorScheme": "Solarized Dark"
}
阳光化的光
"profiles": [
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"colorScheme": "Solarized Light"
}
如果你想全力以赴,做出你自己的古怪方案,你可以把整个方案放在scheme数组中,然后像我们上面做的那样引用。例如,这里有一个更新的 profiles.json
.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles": [
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"colorScheme": "Wacky Scheme"
},
{
// Make changes here to the cmd.exe profile
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "cmd",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
],
// Add custom color schemes to this array
"schemes": [
{
"background": "#9b1771",
"black": "#6eb42c",
"blue": "#2462b3",
"brightBlack": "#6c7465",
"brightBlue": "#527192",
"brightCyan": "#28eeee",
"brightGreen": "#8af51f",
"brightPurple": "#ce93c7",
"brightRed": "#f81515",
"brightWhite": "#fffafa",
"brightYellow": "#f7e455",
"cyan": "#0aa6a8",
"foreground": "#f3eded",
"green": "#421133",
"name": "Wacky Scheme",
"purple": "#714279",
"red": "#df1818",
"white": "#ffffff",
"yellow": "#f8d124"
}
],
// Add any keybinding overrides to this array.
// To unbind a default keybinding, set the command to "unbound"
"keybindings": []
}
多标签支持
就像我们上面提到的,新的Windows终端也支持多标签。你可以拥有同一类型的shell的多个标签,或者你可以将多种类型的shell分布在不同的标签上。默认情况下,当新的微软终端首次启动时,Powershell标签是你开始使用的。通过查看左边的菜单,我们可以看到如何在另一个标签中打开一个传统的cmd shell,并在那里进行工作。如果你需要连接到云中的Azure,这也是一个选项。
添加自定义背景图片
也许基本的颜色对你来说是不够的。你希望你的终端看起来很棒,很独特。为了达到最大的定制化,你可以选择你自己的图像文件作为背景。显然,你甚至可以在那里放一张动画图片。然而,当你试图做工作时,有图像在背景中跳舞,这会让我发疯。要设置你的自定义图像作为新终端的背景,请继续将该文件放在以下目录中。
C:\Users\Chris\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState
一旦你的图像被放置在适当的目录中,你现在需要在profiles.json文件中引用它,像这样。
"profiles": [
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"backgroundImage": "ms-appdata:///roaming/windows-terminal-background.png",
"backgroundImageOpacity": 0.25
},
现在我们看到Powershell终端中令人敬畏的新背景了。
新终端还能做什么?
除了我们上面看到的功能外,新Windows终端还包括VT、ConPty和24位彩色的仿真。我们在上面的定制调整显示了颜色确实看起来很滑稽。这些多个标签的好处是,它们可以访问所有不同的贝壳,如传统的命令行贝壳,PowerShell贝壳,Azure托管的云贝壳,或Windows Subsystem for Linux贝壳。定制是按shell进行的,所以每个shell都可以有自己的颜色、背景图片、透明度等级等等。此外,随着表情符号和字形的广泛流行,微软通过基于GPU加速的DirectWrite/DirectX文本渲染引擎增加了对这些的支持。
新Windows终端摘要
微软的新Windows终端是Windows生态系统中的一个受欢迎的补充。在与难以调整大小、没有标签、有繁琐的定制选项的旧微软控制台共处之后,这个新终端是一股新鲜空气。如果我们在Visual Studio Code上看到的快速和非常令人印象深刻的进展是任何迹象的话,微软的新终端将成为Windows上命令行工作的标准和最佳选择,不需要第三方软件就能获得良好的控制台体验。