原文:https://sspai.com/post/59380 选主题:https://github.com/mbadolato/iTerm2-Color-Schemes 搜主题:https://github.com/mbadolato/iTerm2-Color-Schemes/tree/master/windowsterminal
文件位置:
首先,我们进入 Windows Terminal 的设置文件。在 Windows Terminal 的下拉菜单中,选择 设置 。
跳转到设置的的页面,点击左下角的 打开JSON文件 ,这样我们就打开了JSON文件。
或者 直接 使用路径进入:C:\Users\Administrator\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState
了解结构:
Windows Terminal 的配置文件是一个 JSON 格式的文件,我们会在其中定义全部 Windows Terminal 的属性。简单来讲,这个配置文件包含了如下的几个部分:
- 全局属性:位于 JSON 最外侧,包含有设置亮暗主题、默认 Profile 等项目的配置。
- 环境入口
**profiles**
:一个列表,其中包含有 Windows Terminal 下拉菜单中唤起的各种环境(比如打开 PowerShell 环境、WSL 环境或 SSH 至远程服务器的环境……)与各种环境里 Windows Terminal 的显示方案(比如字体、背景、色彩方案等)。 - 配色主题
**schemes**
:一个配色方案列表,其中包含有 Windows Terminal 在上一项「环境入口」中可以调用的「色彩主题」。 - 快捷键绑定
**keybindings**
:自定义快捷键。
熟悉了 Windows Terminal 配置文件的各项含义之后,我们即可开始对 Windows Terminal 的各项属性进行配置。
更换背景色:
我们先来更换一个背景,注意放置的位置是在 “profiles” 下的 defaults 下面。
"background": "#013456", // 背景色
"acrylicOpacity": 0.8, // 背景透明度
"useAcrylic": true, // 启用毛玻璃
Windows Terminal 的环境配置中可以设置其调用命令(commandline)、字体(fontFace)、颜色方案(colorScheme)、背景颜色(background)与背景图片(backgroundImage)等等。
我们在把更换一个背景图片试试
更换背景图:
有些教程会建议放在 Windows Terminal 安装目录 C:\Users\{用户名}\AppData\Local\Packages\``Microsoft.WindowsTerminal_8wekyb3d8bbwe
里面的 **RoamingState**
这一文件夹,其实这里没必要。
如果你用的是上面的方法,图片放在了 RoamingState 文件夹里,下面的路径必须是 ms-appdata:///roaming/ 开头,代码如下:
"backgroundImage": "ms-appdata:///roaming/a.jpg", // 背景图位置(修改你的图片名称)
"backgroundImageStretchMode": "uniformToFill", // 设置背景图片伸缩模式为「按比例放大」
"backgroundImageOpacity": 0.6 // 图片透明度
如果你不想用上面的方法,就想直接用我网盘的图片,只需要修改你的图片地址即可(注意用反斜杠或双斜杠)。
"backgroundImage":"D:\\OneDrive\\Todo\\@_.jpg", // 背景图位置(修改你的图片名称)
"backgroundImageStretchMode": "uniformToFill", // 设置背景图片伸缩模式为「按比例放大」
"backgroundImageOpacity": 0.1, // 图片透明度
这样,我们就得到了一个非常 Windows 风格的 PowerShell 终端环境:
当然,我们同样可以为其他环境配置相应的背景图案。为 Windows Terminal 的环境设置背景,还可以提示我们当前所处的位置,防止在生产环境做出错误的操作等。不过我目前没有这方面的要求,跳过。

更换配色主题:
Windows Terminal 的色彩主题同样是 JSON 文件,我们可以在上文介绍的 profiles.json
文件的 schemes
属性处,添加自定义的色彩主题。
我们先来 iTerm2 Color Schemes 里选配色,我这里选择了一个 Duotone Dark 主题色,然后我们在 windowsterminal 列表里搜索 Duotone Dark
点进去,复制里面的参数,放在 schemes
下的 中括号里:
之后,我们在 Windows Terminal 配置文件里,定义使用相应的「色彩主题」,即可让这一环境的配色方案生效:
"colorScheme": "Duotone Dark" // 定义主题色
这样,我们的主题就配置好了。
另外,细心的小伙伴发现了,我们既设置了背景图,又设置了主题,系统用哪个呢?答案是都用了,我们可以修改下背景图的透明度看下,这里我修改为0.2,结果如下图:
好了,我们的美化完成,里面还有字体设置和快捷键设置,方式同理,这里就不赘述了。
更改默认终端:
默认是打开powershell,我经常使用的是命令提示符(小黑窗)
主题预览:
上面做记录,最后发现上面的主题色调太显眼,太容易疲惫,所以找了几个我比较喜欢的主题,下面有预览图。
注意:记得修改你的图片地址和文件名哦!
我的配置
不同电脑的终端ID是不同的,记得更换(有三种guid,每台电脑的都不同,对应的是 39行、46行、52行)
这里面的 guid 只能用自己电脑的,如果改错了,无法打开,就清空后保存再次打开就恢复默认了。
// This file was initially generated by Windows Terminal 1.6.10571.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": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", // 默认终端ID
// 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": false,
// 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": {
"backgroundImage": "D:\\OneDrive\\Eagle.library\\images\\JY9IIUHX65L6X.info\\Work Overtime.jpg", // 背景图位置
"backgroundImageStretchMode": "uniformToFill", // 设置背景图片伸缩模式为「按比例放大」
"backgroundImageOpacity": 0.12, // 设置透明度
"colorScheme": "AtelierSulphurpool", // 定义主题色
"useAcrylic": true, // 启用毛玻璃
"acrylicOpacity": 0.9, //毛玻璃透明度,不加它默认就是0.5
"fontFace": "Consolas", // 字体
"fontSize": 12 // 字号
},
"list": [{
// Make changes here to the powershell.exe profile.
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "命令提示符",
"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.
// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
"schemes": [{
"name": "AtelierSulphurpool",
"black": "#202746",
"red": "#c94922",
"green": "#ac9739",
"yellow": "#c08b30",
"blue": "#3d8fd1",
"purple": "#6679cc",
"cyan": "#22a2c9",
"white": "#979db4",
"brightBlack": "#6b7394",
"brightRed": "#c76b29",
"brightGreen": "#293256",
"brightYellow": "#5e6687",
"brightBlue": "#898ea4",
"brightPurple": "#dfe2f1",
"brightCyan": "#9c637a",
"brightWhite": "#f5f7ff",
"background": "#202746",
"foreground": "#979db4",
"cursorColor": "#979db4",
"selectionBackground": "#5e6687"
},
{
"name": "Subliminal",
"black": "#7f7f7f",
"red": "#e15a60",
"green": "#a9cfa4",
"yellow": "#ffe2a9",
"blue": "#6699cc",
"purple": "#f1a5ab",
"cyan": "#5fb3b3",
"white": "#d4d4d4",
"brightBlack": "#7f7f7f",
"brightRed": "#e15a60",
"brightGreen": "#a9cfa4",
"brightYellow": "#ffe2a9",
"brightBlue": "#6699cc",
"brightPurple": "#f1a5ab",
"brightCyan": "#5fb3b3",
"brightWhite": "#d4d4d4",
"background": "#282c35",
"foreground": "#d4d4d4",
"cursorColor": "#c7c7c7",
"selectionBackground": "#484e5b"
}
],
// Add custom actions and keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
"actions": [
// 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+Shift+F to open the search box
{
"command": "find",
"keys": "ctrl+shift+f"
},
// 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"
}
]
}