一、原始配置
在安装了WSL的情况下,缺省的配置如下:
// This file was initially generated by Windows Terminal 0.11.1251.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}",// 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":{// Put settings here that you want to apply to all profiles.},"list":[{// 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": "命令提示符","commandline": "cmd.exe","hidden": false},{"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}","hidden": false,"name": "Azure Cloud Shell","source": "Windows.Terminal.Azure"},{"guid": "{aabae64a-7cf7-5add-b5d6-744e54ab56d6}","hidden": false,"name": "centos","source": "Windows.Terminal.Wsl"}]},// Add custom color schemes to this array.// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes"schemes": [],// 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+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" }]}
各字段说明:
- profiles.defaults 终端默认配置
- profiles.list 终端列表配置
- schemes 样式配置
- keybindings 快捷键配置
二、全局配置
可以在根节点下添加全局配置:
{"alwaysShowTabs" : true,"copyOnSelect" : true,"defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}","initialCols" : 120,"initialRows" : 30,"requestedTheme" : "system","showTabsInTitlebar" : true,"showTerminalTitleInTitlebar" : true,"wordDelimiters" : " ./\\()\"':,.;<>~!@#$%^&*|+=[]{}~?\u2502"}
这些配置大都见名知意,不赘述。
如果在老版本的wt中,可以放到globals节点下(参考:https://github.com/microsoft/terminal/issues/5458):
{globals: {"alwaysShowTabs" : true,"copyOnSelect" : true,"defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}","initialCols" : 120,"initialRows" : 30,"requestedTheme" : "system","showTabsInTitlebar" : true,"showTerminalTitleInTitlebar" : true,"wordDelimiters" : " ./\\()\"':,.;<>~!@#$%^&*|+=[]{}~?\u2502"}}
三、为指定的shell进行个性化配置
样式与背景
首先我们可以在schemes中创建自定义的样式,比如:
{// Add custom color schemes to this array"schemes": [{"name": "AdventureTime","black": "#050404","red": "#bd0013","green": "#4ab118","yellow": "#e7741e","blue": "#0f4ac6","purple": "#665993","cyan": "#70a598","white": "#f8dcc0","brightBlack": "#4e7cbf","brightRed": "#fc5f5a","brightGreen": "#9eff6e","brightYellow": "#efc11a","brightBlue": "#1997c6","brightPurple": "#9b5953","brightCyan": "#c8faf4","brightWhite": "#f6f5fb","background": "#1f1d45","foreground": "#f8dcc0"}],}
在指定的shell中配置:
{"acrylicOpacity" : 0.5,"background": "#fff","backgroundImage": "D:\\User\\quanzaiyu\\bg.jpg","backgroundImageOpacity": 0.9,"colorScheme": "AdventureTime","guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}","name": "Windows PowerShell","tabTitle" : "PowerShell","commandline": "powershell.exe","hidden": false},
字体与指针
在指定的shell中配置:
{"cursorColor" : "#FFFFFF","cursorShape" : "bar","fontFace" : "Consolas","fontSize" : 16,"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}","name": "Windows PowerShell","tabTitle" : "PowerShell","commandline": "powershell.exe","hidden": false},
其他配置
可以在指定的shell中进行以下配置:
icon设置shell的图标closeOnExit输入exit时是否关闭选项卡commandline要执行的命令行tabTitle自定义选项卡标题hidden是否隐藏此shell
示例:
"icon": "D:\\User\\quanzaiyu\\bg\\git.ico","closeOnExit" : true,"commandline" : "wsl.exe -d ubuntu18","tabTitle" : "ubuntu18",
三、定制自己喜欢的Scheme
首先克隆这个项目:iTerm2-Color-Schemes:
git clone https://github.com/mbadolato/iTerm2-Color-Schemes.git
在windowsterminal目录下找到自己喜欢的Scheme,将其代码复制到profiles.json中的schemes节点下即可。
四、最终的配置
最终的配置如下,做个备份,大家也可以参考下:
// This file was initially generated by Windows Terminal 1.1.2233.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}",// 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": true,"alwaysShowTabs" : true,"initialCols" : 120,"initialRows" : 30,"requestedTheme" : "system","showTabsInTitlebar" : true,"showTerminalTitleInTitlebar" : true,"wordDelimiters" : " ./\\()\"':,.;<>~!@#$%^&*|+=[]{}~?\u2502",// 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."acrylicOpacity" : 0.5,"background": "#fff","colorScheme": "AdventureTime","backgroundImageOpacity": 0.9,"cursorColor" : "#FFFFFF","cursorShape" : "bar","fontFace" : "'Fira Code', 'Sarasa Term SC Regular', Consolas, 'Courier New', monospace","fontSize" : 16,"historySize" : 9001,"padding" : "0, 0, 0, 0","startingDirectory": "./","snapOnInput" : true,"useAcrylic" : false,"closeOnExit" : true,"hidden": false},"list":[{// Make changes here to the cmd.exe profile"name": "命令提示符","commandline": "cmd.exe","tabTitle" : "CMD","backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg4.jpg","icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png","guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}"},{// Make changes here to the powershell.exe profile"name": "Windows PowerShell","commandline": "powershell.exe","tabTitle" : "PowerShell","backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg1.jpg","icon" : "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png","guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}"},{"name": "git bash","commandline": "C:\\Program Files\\Git\\bin\\bash.exe","tabTitle" : "GitBash","backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg5.jpg","icon": "D:\\Users\\quanzaiyu\\.wt\\icons\\git.ico","guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b7}"},{"name": "Azure Cloud Shell","guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}","backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg4.jpg","source": "Windows.Terminal.Azure"},{"name": "CentOS","guid": "{aabae64a-7cf7-5add-b5d6-744e54ab56d6}","backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg4.jpg","source": "Windows.Terminal.Wsl"},{"name": "Ubuntu","guid": "{2c4de342-38b7-51cf-b940-2309a097f518}","backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg4.jpg","tabTitle" : "Ubuntu","source": "Windows.Terminal.Wsl"},{"name": "Kail","guid": "{46ca431a-3a87-5fb3-83cd-11ececc031d2}","backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg4.jpg","tabTitle" : "Kail","source": "Windows.Terminal.Wsl"}]},// Add custom color schemes to this array.// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes"schemes": [{"name": "Dark+","black": "#000000","red": "#cd3131","green": "#0dbc79","yellow": "#e5e510","blue": "#2472c8","purple": "#bc3fbc","cyan": "#11a8cd","white": "#e5e5e5","brightBlack": "#666666","brightRed": "#f14c4c","brightGreen": "#23d18b","brightYellow": "#f5f543","brightBlue": "#3b8eea","brightPurple": "#d670d6","brightCyan": "#29b8db","brightWhite": "#e5e5e5","background": "#0e0e0e","foreground": "#cccccc"},{"name": "AdventureTime","black": "#050404","red": "#bd0013","green": "#4ab118","yellow": "#e7741e","blue": "#0f4ac6","purple": "#665993","cyan": "#70a598","white": "#f8dcc0","brightBlack": "#4e7cbf","brightRed": "#fc5f5a","brightGreen": "#9eff6e","brightYellow": "#efc11a","brightBlue": "#1997c6","brightPurple": "#9b5953","brightCyan": "#c8faf4","brightWhite": "#f6f5fb","background": "#1f1d45","foreground": "#f8dcc0"}],// 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+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" }]}
