好久没有更新文章了哈哈。今天的文章分享一下 Windows Terminal 的配置文件。笔者目前在 Windows 平台上使用的终端是 Windows Terminal 和 PowerShell6,整体的体验是不错的。
安装
- 可以在仓库页面下载到最新的软件安装包。展开 Assets 菜单,下载其中的
.mixbundle
文件,之后双击打开即可运行。 - 可以在 Microsoft Store 搜索下载。
- 可以使用 scoop 安装下载。
scoop info windows-terminal
scoop install windows-terminal
虚拟终端与 Shell
终端是一个比较有趣的概念,现在系统上使用的终端其实都是「虚拟终端」,基本已经和「shell」这个概念绑定在了一起。系统自带的 Cmd、PowerShell 就已经将终端和其 Shell 进行了整合。打开 Cmd 的同时开启了系统的一个虚拟终端,虚拟终端使用的 Shell 为 Cmd。
终端可以有自己的特性,不同 Shell 可以有不同的指令集实现,两者其实互不影响。Windows Terminal 就仅仅提供了虚拟终端的功能,使用的 Shell 依然是系统所包含的。目前 Windows 平台上较为推荐的 Shell 是 PowerShell。
可以在这里下载到 PowerShell。目前最近版本已经更替到了7.0
,但依然推荐使用其6.0
的稳定版本,v6.2.6
。
关于虚拟终端与 Shell 的更多介绍,可以移步这里。作者在文中讲述了一些有趣的历史与术语概念。
配置终端
与常用的终端不同,Windows Terminal 的设置没有界面,只能通过编辑配置文件的方式进行调整。在顶部的下拉菜单中可以找到设置入口,将使用默认应用打开.json
后缀的配置文件。
可以在这里查到所有的配置文件选项。配置文件的大体结构如下:
{
"$schema": "https://aka.ms/terminal-profiles-schema",
// global settings
"profiles": {
// profile settings
"defaults": {
// default settings
},
"list": [
// profile lists
]
},
"schemes": [], // color scheme settings
"keybindings": [
// key bindings
]
}
- 顶部的
$schema
是软件生成的固定内容。 //global settings
位置可以设置很多终端表现相关的设置选项。profile
处设置 Shell 相关的配置选项。schemes
处设置颜色配置相关的配置选项。keybindings
设置键盘组合键相关的配置选项。
整个配置文件的内容不算太多,推荐大家可以去文档浏览一遍有那些可选项,具体的说明解释在文档里都有解释和效果展示,笔者这里不过多介绍啦。
完整的配置文件
分享笔者自己完整的配置文件。
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"theme": "dark",
"confirmCloseAllTabs": false,
"copyOnSelect": true,
"copyFormatting": true,
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles": {
"defaults": {
"cursorShape": "underscore",
"colorScheme": "One Half Dark",
"background": "#1e1e1e",
"selectionBackground": "#1062cc",
"fontFace": "fira code retina",
"fontSize": 10,
"icon": null,
"historySize": 1024
},
"list": [
{
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "PS5",
"hidden": true,
"commandline": "powershell.exe"
},
{
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"name": "PS6",
"hidden": false,
"source": "Windows.Terminal.PowershellCore"
},
{
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Cmd",
"hidden": false,
"commandline": "cmd.exe"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"name": "Azure Cloud Shell",
"hidden": true,
"source": "Windows.Terminal.Azure"
}
]
},
// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
"schemes": [],
// To learn more about keybindings, visit https://aka.ms/terminal-keybindings
"keybindings": [
{ "command": "paste", "keys": "ctrl+v" },
{ "command": "find", "keys": "ctrl+f" },
{ "command": "closeTab", "keys": "ctrl+w" },
{ "command": "newTab", "keys": "ctrl+t" },
{ "command": "openSettings", "keys": "ctrl+," },
{ "command": "toggleFullscreen", "keys": "alt+enter" },
{ "command": "toggleFullscreen", "keys": "f11" },
{ "command": "nextTab", "keys": "ctrl+tab" },
{
"command": { "action": "switchToTab", "index": 0 },
"keys": "ctrl+1"
},
{
"command": { "action": "switchToTab", "index": 1 },
"keys": "ctrl+2"
},
{
"command": { "action": "switchToTab", "index": 2 },
"keys": "ctrl+3"
},
{
"command": { "action": "switchToTab", "index": 3 },
"keys": "ctrl+4"
},
{ "command": { "action": "switchToTab", "index": 4 }, "keys": "ctrl+5" }
]
}
淳朴简约,没有花里胡哨的界面配置,节约性能哈哈。强烈欢迎大家在下方留言评论,有啥想要的配置项或者不同的地方,笔者帮着去查阅文档。
关于 Shell 的配置,放到下一篇文章更新。共同学习!