Windows Terminal终端安装与美化

本文最后更新于:2022年4月9日 中午

windows terminal 是微软Build大会上推出的一款的全新终端,用来代替cmder之类的第三方终端。同时该终端依然符合我们的目标和要求,快速、高效,并且不会消耗大量内存和电源。

1.安装

可以在微软商店里面进行安装,系统要求是Windows 1903 (build >= 10.0.18362.0) 及以上。

或者在Windows Terminal的Github项目,进入Releases发布模块,下载第一个进行安装。

2.自定义配置

官网:https://docs.microsoft.com/en-us/windows/terminal/customize-settings/profile-settings

Windows Terminal提供了许多设置和配置选项,可以对Terminal的外观自定义设置。配置文件格式为json,具体参数信息可参见微软官网。

1.可以使用Ctrl+滑轮调节字体大小
2.可以使用Ctrl+Shift+滑轮调节界面的透明度
3.可以使用ctrl+Shift+d进行界面多开
4.可以使用ctrl+,或者顶部菜单打开设置
5.可以按住alt 再点击设置打开defaults.json修改配色、按键以及各种设置

3.使用win+r快捷键打开

Windows依次打开设置—>应用—>应用和功能—>应用执行别名,可以看到,已安装好的WT程序以及它的别名:wt.exe。参见下图:

win+r 打开运行窗口,输入”wt.exe“即可打开Window Terminal

4.右键菜单在任意文件夹下打开 WT

  1. 打开 C:\Users\用户名\AppData\Local

  2. 建立terminal文件夹

  3. 准备一张作为icon的图片,这里为wt.ico

    图标地址:https://raw.githubusercontent.com/microsoft/terminal/master/res/terminal.ico

  4. wt.ico放入terminal文件夹,新建一个空白的reg注册表文件,命名为wt.reg

  5. 以记事本打开并编辑wt.reg文件,写入如下语句,这里的%USERPROFILE%可以换成绝对路径C:\Users\用户名。

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
    @=”打开终端”
    “Icon”=”%USERPROFILE%\AppData\Local\Terminal\wt.ico”

    [HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
    @=”C:\Users\用户名\AppData\Local\Microsoft\WindowsApps\wt.exe”

  6. 双击wt.reg,右键查看已经存在快捷方式。配合前面的settings.json"startingDirectory": null属性设置,可以做到右键点击从当前目录打开终端。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    settings.json文件下:

    {
    // Make changes here to the powershell.exe profile.
    "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
    "closeOnExit" : true,
    "name": "Windows PowerShell",
    "commandline": "powershell.exe",
    "fontFace" : "Consolas",
    "fontSize" : 12,
    "hidden": false,
    "snapOnInput" : true,
    "tabTitle" : "Powershell",
    "acrylicOpacity": 0.9,
    "useAcrylic": true,
    "startingDirectory": null //新添加的
    },

5.添加git-bash

settings.json文件中找到profiles选项,添加如下配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
// Make changes here to the git bash.exe profile.
// 预先从在线GUID生成器生成,只要和其他终端不重复即可
"guid": "{5772f1ce-4f65-46a8-fe34-f91e7c73276a}",
"closeOnExit" : true,
// 此处要预先把准备好的bash图标放在该文件夹下
"icon": "C:\\Users\\ZHENG\\AppData\\Local\\terminal\\git_bash.ico",
"name": "Git Bash",
"fontFace" : "Consolas",
"fontSize" : 12,
// 修改成你的新的终端路径
"commandline": "D:\\Git\\bin\\bash.exe",
"hidden": false,
"snapOnInput" : true,
"acrylicOpacity": 0.9,
"useAcrylic": true,
"startingDirectory": null
}

6.最终效果

保存所有配置文件之后,配置将会立刻生效。可以在 Windows Terminal 中看到新增的 Bash 终端。

附录

terminal文件夹下所有文件下载

下载链接:bdex://5d4bae14d6db1841ccfc3ab33e1e2fd13bd8ead5

下载后解压到C:\Users\用户名\AppData\Local文件夹下,修改wt.reg文件,再双击执行即可。

下载方法参见:CDNDrive 文件上传与下载

或者直接下载以下图片:

wt

git_bash

settings.json 参考

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// This file was initially generated by Windows Terminal 1.0.1401.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.

// 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}",
"initialCols": 80,
"initialRows": 20,
"showTerminalTitleInTitlebar": true,
"snapToGridOnResize": true,

// You can add more global application settings here.
// To learn more about global settings, visit https://aka.ms/terminal-global-settings

// If enabled, selections are automatically copied to your clipboard.
"copyOnSelect": true,

// If enabled, formatted data is also copied to your clipboard
"copyFormatting": false,

// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles.
"suppressApplicationTitle": true
},
"list":
[
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"closeOnExit" : true,
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"fontFace" : "Consolas",
"fontSize" : 12,
"hidden": false,
"snapOnInput" : true,
"tabTitle" : "Powershell",
"acrylicOpacity": 0.9,
"useAcrylic": true,
"startingDirectory": null
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"closeOnExit" : true,
"name": "命令提示符",
"fontFace" : "Consolas",
"fontSize" : 12,
"commandline": "cmd.exe",
"hidden": false,
"snapOnInput" : true,
"acrylicOpacity": 0.9,
"useAcrylic": true,
"startingDirectory": null
},
{
// Make changes here to the git bash.exe profile.
"guid": "{5772f1ce-4f65-46a8-fe34-f91e7c73276a}",
"closeOnExit" : true,
"icon": "C:\\Users\\ZHENG\\AppData\\Local\\terminal\\git_bash.ico",
"name": "Git Bash",
"fontFace" : "Consolas",
"fontSize" : 12,
"commandline": "D:\\Git\\bin\\bash.exe",
"hidden": false,
"snapOnInput" : true,
"acrylicOpacity": 0.9,
"useAcrylic": true,
"startingDirectory": null
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
]
},

// Add custom color schemes to this array.
// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
"schemes": [
{
"name": "Nord",
"background": "#2e3440",
"foreground": "#eceff4",
"brightBlack": "#2e3440",
"brightBlue": "#5e81ac",
"brightCyan": "#8fbcbb",
"brightGreen": "#a3be8c",
"brightPurple": "#b48ead",
"brightRed": "#bf616a",
"brightWhite": "#eceff4",
"brightYellow": "#ebcb8b",
"black": "#2e3440",
"blue": "#5e81ac",
"cyan": "#8fbcbb",
"green": "#a3be8c",
"purple": "#b48ead",
"red": "#bf616a",
"white": "#eceff4",
"yellow": "#ebcb8b"
}
],

// Add custom keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about keybindings, visit https://aka.ms/terminal-keybindings
"keybindings":
[
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
// To learn more about selection, visit https://aka.ms/terminal-selection
{ "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
{ "command": "paste", "keys": "ctrl+v" },

// Press Ctrl+F to open the search box
{ "command": "find", "keys": "ctrl+f" },

// Press Ctrl+w to closetab
{ "command": "closeTab", "keys": "ctrl+w"},

// Press Alt+Shift+D to open a new pane.
// - "split": "auto" makes this pane open in the direction that provides the most surface area.
// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
// To learn more about panes, visit https://aka.ms/terminal-panes
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
]
}

参考资料

https://lanlan2017.github.io/blog/ed5250a2/

https://blog.csdn.net/weixin_43870742/article/details/100830921?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-1&spm=1001.2101.3001.4242

https://www.cnblogs.com/kuronekonano/p/12519447.html

https://blog.csdn.net/WPwalter/article/details/100159481