一、原始配置

在安装了WSL的情况下,缺省的配置如下:

  1. // This file was initially generated by Windows Terminal 0.11.1251.0
  2. // It should still be usable in newer versions, but newer versions might have additional
  3. // settings, help text, or changes that you will not see unless you clear this file
  4. // and let us generate a new one for you.
  5. // To view the default settings, hold "alt" while clicking on the "Settings" button.
  6. // For documentation on these settings, see: https://aka.ms/terminal-documentation
  7. {
  8. "$schema": "https://aka.ms/terminal-profiles-schema",
  9. "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
  10. // You can add more global application settings here.
  11. // To learn more about global settings, visit https://aka.ms/terminal-global-settings
  12. // If enabled, selections are automatically copied to your clipboard.
  13. "copyOnSelect": false,
  14. // If enabled, formatted data is also copied to your clipboard
  15. "copyFormatting": false,
  16. // A profile specifies a command to execute paired with information about how it should look and feel.
  17. // Each one of them will appear in the 'New Tab' dropdown,
  18. // and can be invoked from the commandline with `wt.exe -p xxx`
  19. // To learn more about profiles, visit https://aka.ms/terminal-profile-settings
  20. "profiles":
  21. {
  22. "defaults":
  23. {
  24. // Put settings here that you want to apply to all profiles.
  25. },
  26. "list":
  27. [
  28. {
  29. // Make changes here to the powershell.exe profile.
  30. "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
  31. "name": "Windows PowerShell",
  32. "commandline": "powershell.exe",
  33. "hidden": false
  34. },
  35. {
  36. // Make changes here to the cmd.exe profile.
  37. "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
  38. "name": "命令提示符",
  39. "commandline": "cmd.exe",
  40. "hidden": false
  41. },
  42. {
  43. "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
  44. "hidden": false,
  45. "name": "Azure Cloud Shell",
  46. "source": "Windows.Terminal.Azure"
  47. },
  48. {
  49. "guid": "{aabae64a-7cf7-5add-b5d6-744e54ab56d6}",
  50. "hidden": false,
  51. "name": "centos",
  52. "source": "Windows.Terminal.Wsl"
  53. }
  54. ]
  55. },
  56. // Add custom color schemes to this array.
  57. // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
  58. "schemes": [],
  59. // Add custom keybindings to this array.
  60. // To unbind a key combination from your defaults.json, set the command to "unbound".
  61. // To learn more about keybindings, visit https://aka.ms/terminal-keybindings
  62. "keybindings":
  63. [
  64. // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
  65. // These two lines additionally bind them to Ctrl+C and Ctrl+V.
  66. // To learn more about selection, visit https://aka.ms/terminal-selection
  67. { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
  68. { "command": "paste", "keys": "ctrl+v" },
  69. // Press Ctrl+Shift+F to open the search box
  70. { "command": "find", "keys": "ctrl+shift+f" },
  71. // Press Alt+Shift+D to open a new pane.
  72. // - "split": "auto" makes this pane open in the direction that provides the most surface area.
  73. // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
  74. // To learn more about panes, visit https://aka.ms/terminal-panes
  75. { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
  76. ]
  77. }

各字段说明:

  • profiles.defaults 终端默认配置
  • profiles.list 终端列表配置
  • schemes 样式配置
  • keybindings 快捷键配置

二、全局配置

可以在根节点下添加全局配置:

  1. {
  2. "alwaysShowTabs" : true,
  3. "copyOnSelect" : true,
  4. "defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
  5. "initialCols" : 120,
  6. "initialRows" : 30,
  7. "requestedTheme" : "system",
  8. "showTabsInTitlebar" : true,
  9. "showTerminalTitleInTitlebar" : true,
  10. "wordDelimiters" : " ./\\()\"':,.;<>~!@#$%^&*|+=[]{}~?\u2502"
  11. }

这些配置大都见名知意,不赘述。

如果在老版本的wt中,可以放到globals节点下(参考:https://github.com/microsoft/terminal/issues/5458):

  1. {
  2. globals: {
  3. "alwaysShowTabs" : true,
  4. "copyOnSelect" : true,
  5. "defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
  6. "initialCols" : 120,
  7. "initialRows" : 30,
  8. "requestedTheme" : "system",
  9. "showTabsInTitlebar" : true,
  10. "showTerminalTitleInTitlebar" : true,
  11. "wordDelimiters" : " ./\\()\"':,.;<>~!@#$%^&*|+=[]{}~?\u2502"
  12. }
  13. }

三、为指定的shell进行个性化配置

样式与背景

首先我们可以在schemes中创建自定义的样式,比如:

  1. {
  2. // Add custom color schemes to this array
  3. "schemes": [
  4. {
  5. "name": "AdventureTime",
  6. "black": "#050404",
  7. "red": "#bd0013",
  8. "green": "#4ab118",
  9. "yellow": "#e7741e",
  10. "blue": "#0f4ac6",
  11. "purple": "#665993",
  12. "cyan": "#70a598",
  13. "white": "#f8dcc0",
  14. "brightBlack": "#4e7cbf",
  15. "brightRed": "#fc5f5a",
  16. "brightGreen": "#9eff6e",
  17. "brightYellow": "#efc11a",
  18. "brightBlue": "#1997c6",
  19. "brightPurple": "#9b5953",
  20. "brightCyan": "#c8faf4",
  21. "brightWhite": "#f6f5fb",
  22. "background": "#1f1d45",
  23. "foreground": "#f8dcc0"
  24. }
  25. ],
  26. }

在指定的shell中配置:

  1. {
  2. "acrylicOpacity" : 0.5,
  3. "background": "#fff",
  4. "backgroundImage": "D:\\User\\quanzaiyu\\bg.jpg",
  5. "backgroundImageOpacity": 0.9,
  6. "colorScheme": "AdventureTime",
  7. "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
  8. "name": "Windows PowerShell",
  9. "tabTitle" : "PowerShell",
  10. "commandline": "powershell.exe",
  11. "hidden": false
  12. },

字体与指针

在指定的shell中配置:

  1. {
  2. "cursorColor" : "#FFFFFF",
  3. "cursorShape" : "bar",
  4. "fontFace" : "Consolas",
  5. "fontSize" : 16,
  6. "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
  7. "name": "Windows PowerShell",
  8. "tabTitle" : "PowerShell",
  9. "commandline": "powershell.exe",
  10. "hidden": false
  11. },

其他配置

可以在指定的shell中进行以下配置:

  • icon 设置shell的图标
  • closeOnExit 输入exit时是否关闭选项卡
  • commandline 要执行的命令行
  • tabTitle 自定义选项卡标题
  • hidden 是否隐藏此shell

示例:

  1. "icon": "D:\\User\\quanzaiyu\\bg\\git.ico",
  2. "closeOnExit" : true,
  3. "commandline" : "wsl.exe -d ubuntu18",
  4. "tabTitle" : "ubuntu18",

三、定制自己喜欢的Scheme

首先克隆这个项目:iTerm2-Color-Schemes

  1. git clone https://github.com/mbadolato/iTerm2-Color-Schemes.git

在windowsterminal目录下找到自己喜欢的Scheme,将其代码复制到profiles.json中的schemes节点下即可。

四、最终的配置

最终的配置如下,做个备份,大家也可以参考下:

  1. // This file was initially generated by Windows Terminal 1.1.2233.0
  2. // It should still be usable in newer versions, but newer versions might have additional
  3. // settings, help text, or changes that you will not see unless you clear this file
  4. // and let us generate a new one for you.
  5. // To view the default settings, hold "alt" while clicking on the "Settings" button.
  6. // For documentation on these settings, see: https://aka.ms/terminal-documentation
  7. {
  8. "$schema": "https://aka.ms/terminal-profiles-schema",
  9. "defaultProfile": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
  10. // You can add more global application settings here.
  11. // To learn more about global settings, visit https://aka.ms/terminal-global-settings
  12. // If enabled, selections are automatically copied to your clipboard.
  13. "copyOnSelect": true,
  14. // If enabled, formatted data is also copied to your clipboard
  15. "copyFormatting": true,
  16. "alwaysShowTabs" : true,
  17. "initialCols" : 120,
  18. "initialRows" : 30,
  19. "requestedTheme" : "system",
  20. "showTabsInTitlebar" : true,
  21. "showTerminalTitleInTitlebar" : true,
  22. "wordDelimiters" : " ./\\()\"':,.;<>~!@#$%^&*|+=[]{}~?\u2502",
  23. // A profile specifies a command to execute paired with information about how it should look and feel.
  24. // Each one of them will appear in the 'New Tab' dropdown,
  25. // and can be invoked from the commandline with `wt.exe -p xxx`
  26. // To learn more about profiles, visit https://aka.ms/terminal-profile-settings
  27. "profiles":
  28. {
  29. "defaults":
  30. {
  31. // Put settings here that you want to apply to all profiles.
  32. "acrylicOpacity" : 0.5,
  33. "background": "#fff",
  34. "colorScheme": "AdventureTime",
  35. "backgroundImageOpacity": 0.9,
  36. "cursorColor" : "#FFFFFF",
  37. "cursorShape" : "bar",
  38. "fontFace" : "'Fira Code', 'Sarasa Term SC Regular', Consolas, 'Courier New', monospace",
  39. "fontSize" : 16,
  40. "historySize" : 9001,
  41. "padding" : "0, 0, 0, 0",
  42. "startingDirectory": "./",
  43. "snapOnInput" : true,
  44. "useAcrylic" : false,
  45. "closeOnExit" : true,
  46. "hidden": false
  47. },
  48. "list":
  49. [
  50. {
  51. // Make changes here to the cmd.exe profile
  52. "name": "命令提示符",
  53. "commandline": "cmd.exe",
  54. "tabTitle" : "CMD",
  55. "backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg4.jpg",
  56. "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
  57. "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}"
  58. },
  59. {
  60. // Make changes here to the powershell.exe profile
  61. "name": "Windows PowerShell",
  62. "commandline": "powershell.exe",
  63. "tabTitle" : "PowerShell",
  64. "backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg1.jpg",
  65. "icon" : "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
  66. "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}"
  67. },
  68. {
  69. "name": "git bash",
  70. "commandline": "C:\\Program Files\\Git\\bin\\bash.exe",
  71. "tabTitle" : "GitBash",
  72. "backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg5.jpg",
  73. "icon": "D:\\Users\\quanzaiyu\\.wt\\icons\\git.ico",
  74. "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b7}"
  75. },
  76. {
  77. "name": "Azure Cloud Shell",
  78. "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
  79. "backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg4.jpg",
  80. "source": "Windows.Terminal.Azure"
  81. },
  82. {
  83. "name": "CentOS",
  84. "guid": "{aabae64a-7cf7-5add-b5d6-744e54ab56d6}",
  85. "backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg4.jpg",
  86. "source": "Windows.Terminal.Wsl"
  87. },
  88. {
  89. "name": "Ubuntu",
  90. "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
  91. "backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg4.jpg",
  92. "tabTitle" : "Ubuntu",
  93. "source": "Windows.Terminal.Wsl"
  94. },
  95. {
  96. "name": "Kail",
  97. "guid": "{46ca431a-3a87-5fb3-83cd-11ececc031d2}",
  98. "backgroundImage": "D:\\Users\\quanzaiyu\\.wt\\bg\\bg4.jpg",
  99. "tabTitle" : "Kail",
  100. "source": "Windows.Terminal.Wsl"
  101. }
  102. ]
  103. },
  104. // Add custom color schemes to this array.
  105. // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
  106. "schemes": [
  107. {
  108. "name": "Dark+",
  109. "black": "#000000",
  110. "red": "#cd3131",
  111. "green": "#0dbc79",
  112. "yellow": "#e5e510",
  113. "blue": "#2472c8",
  114. "purple": "#bc3fbc",
  115. "cyan": "#11a8cd",
  116. "white": "#e5e5e5",
  117. "brightBlack": "#666666",
  118. "brightRed": "#f14c4c",
  119. "brightGreen": "#23d18b",
  120. "brightYellow": "#f5f543",
  121. "brightBlue": "#3b8eea",
  122. "brightPurple": "#d670d6",
  123. "brightCyan": "#29b8db",
  124. "brightWhite": "#e5e5e5",
  125. "background": "#0e0e0e",
  126. "foreground": "#cccccc"
  127. },
  128. {
  129. "name": "AdventureTime",
  130. "black": "#050404",
  131. "red": "#bd0013",
  132. "green": "#4ab118",
  133. "yellow": "#e7741e",
  134. "blue": "#0f4ac6",
  135. "purple": "#665993",
  136. "cyan": "#70a598",
  137. "white": "#f8dcc0",
  138. "brightBlack": "#4e7cbf",
  139. "brightRed": "#fc5f5a",
  140. "brightGreen": "#9eff6e",
  141. "brightYellow": "#efc11a",
  142. "brightBlue": "#1997c6",
  143. "brightPurple": "#9b5953",
  144. "brightCyan": "#c8faf4",
  145. "brightWhite": "#f6f5fb",
  146. "background": "#1f1d45",
  147. "foreground": "#f8dcc0"
  148. }
  149. ],
  150. // Add custom keybindings to this array.
  151. // To unbind a key combination from your defaults.json, set the command to "unbound".
  152. // To learn more about keybindings, visit https://aka.ms/terminal-keybindings
  153. "keybindings":
  154. [
  155. // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
  156. // These two lines additionally bind them to Ctrl+C and Ctrl+V.
  157. // To learn more about selection, visit https://aka.ms/terminal-selection
  158. { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
  159. { "command": "paste", "keys": "ctrl+v" },
  160. // Press Ctrl+Shift+F to open the search box
  161. { "command": "find", "keys": "ctrl+shift+f" },
  162. // Press Alt+Shift+D to open a new pane.
  163. // - "split": "auto" makes this pane open in the direction that provides the most surface area.
  164. // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
  165. // To learn more about panes, visit https://aka.ms/terminal-panes
  166. { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
  167. ]
  168. }