微软推出的Windows terminal可作为CMD的启动器并随心所欲配置主题,推荐

一、安装Windows terminal

Microsoft Store搜索Windows terminal
image.png

选择第一个安装即可,第二个为预览版

二、选择主题

Windows terminal有大量的主题可以选择,如果达不到您的要求,还可以自己进行配置
登陆如下网址,选择一个你喜欢的主题复制主题代码
https://atomcorp.github.io/themes/
用Windows Terminal启动CMD及配置 - 图3

三、配置主题

打开Windows terminal
Win+R运行,输入wt
用Windows Terminal启动CMD及配置 - 图4
点击Windows terminal中的下拉箭头选择设置,打开配置Windows Terminal的Json文件。
用Windows Terminal启动CMD及配置 - 图5

将复制的主题代码粘贴到schemes里面,主题配置像是个集合,应该可以支持存放多个主题配置代码,name为标识,用于设置终端应用哪个主题

在list中分别配置PowerShell的主题和cmd的主题,添加如下代码即可应用对应的主题。
注意:这里配置的主题只是在Windows Terminal中打开PowerShell和cmd所展示的主题,原始的cmd和PowerShell主题不会变化。

  1. "colorScheme":"WarmNeon"

WarmNeon为我配置的主题name
用Windows Terminal启动CMD及配置 - 图6
配置启动Windows Terminal默认打开的终端
复制上图中命令提示行的guid,粘贴到defaultProfile中,这样打开Windows Terminal默认启动的就是cmd终端了。
用Windows Terminal启动CMD及配置 - 图7

四、更高级的打开方式

通过地址栏启动

在配置文件中添加如下代码,就可以像cmd一样在任意文件夹地址栏输入wt就可以在当前文件夹下启动wt
%localappdata%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

  1. "startingDirectory": "."

image.png
image.png
image.png

通过右键菜单启动

添加右键菜单,在任意路径下右键选择Windows Terminal启动
https://github.com/microsoft/terminal/issues/1060

  1. Windows Registry Editor Version 5.00
  2. ;Binary data is just UTF16 (LE) split every 2 bytes with a comma
  3. ;Conversion done with https://onlineutf8tools.com/convert-utf8-to-utf16?hex=true&little-endian=true&space=false&chain=split-string%253Fsplit-by-length%253Dtrue%2526separator%253D%252C
  4. ;User action
  5. [HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminal]
  6. @="Open Terminal here"
  7. ;"Icon"="%USERPROFILE%\Pictures\Icons\terminal.ico" (Location to ICO or comment out to hide icon)
  8. "Icon"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,00,45,00,25,00,5c,00,50,00,69,00,63,00,74,00,75,00,72,00,65,00,73,00,5c,00,49,00,63,00,6f,00,6e,00,73,00,5c,00,74,00,65,00,72,00,6d,00,69,00,6e,00,61,00,6c,00,2e,00,69,00,63,00,6f,00
  9. ;User action command
  10. [HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminal\command]
  11. ;@="%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe -d ."
  12. @=hex(2):25,00,4c,00,4f,00,43,00,41,00,4c,00,41,00,50,00,50,00,44,00,41,00,54,00,41,00,25,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,41,00,70,00,70,00,73,00,5c,00,77,00,74,00,2e,00,65,00,78,00,65,00,20,00,2d,00,64,00,20,00,2e,00
  13. ;Admin action
  14. [HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminalAdmin]
  15. @="Open Terminal here (Admin)"
  16. ;Show the UAC shield on the action
  17. "HasLUAShield"=""
  18. ;"Icon"="%USERPROFILE%\Pictures\Icons\terminal.ico" (Location to ICO or comment out to hide icon)
  19. "Icon"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,4c,00,45,00,25,00,5c,00,50,00,69,00,63,00,74,00,75,00,72,00,65,00,73,00,5c,00,49,00,63,00,6f,00,6e,00,73,00,5c,00,74,00,65,00,72,00,6d,00,69,00,6e,00,61,00,6c,00,2e,00,69,00,63,00,6f,00
  20. ;Admin action command
  21. [HKEY_CLASSES_ROOT\Directory\Background\shell\WindowsTerminalAdmin\command]
  22. @="PowerShell -WindowStyle Hidden -Command \"Start-Process wt -ArgumentList '-d','.' -Verb runAs\""

image.png

为Windows Terminal配置新的Shell与默认Shell(以PowerShell Core 7为例)

%localappdata%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

  1. {
  2. "$schema": "https://aka.ms/terminal-profiles-schema",
  3. //"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
  4. //默认编辑器guid
  5. "defaultProfile": "{91F0E618-9220-4D55-B8A3-E1B5A663024E}",
  6. "profiles":
  7. {
  8. "defaults":
  9. {
  10. // Put settings here that you want to apply to all profiles
  11. },
  12. "list":
  13. [
  14. {
  15. // Make changes here to the powershell.exe profile
  16. "guid": "{91F0E618-9220-4D55-B8A3-E1B5A663024E}",
  17. "name": "Windows PowerShellCore 7",
  18. // 注意:一定要写上 -nologo,否则开启 powershll 会有一段话输出,很讨厌!
  19. //"commandline": "E:\\Program Files\\PowerShell\\7\\pwsh.exe -nologo",
  20. "commandline": "E:\\Program Files\\PowerShell\\7\\pwsh.exe",
  21. "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
  22. // 设置运行目录为当前目录
  23. "startingDirectory": ".",
  24. "colorScheme": "Campbell",
  25. "antialiasingMode": "grayscale",
  26. "closeOnExit": "graceful",
  27. "cursorShape": "bar",
  28. "fontFace": "Cascadia Mono",
  29. "fontSize": 12,
  30. "hidden": false,
  31. "historySize": 9001,
  32. "padding": "8, 8, 8, 8",
  33. "snapOnInput": true,
  34. "useAcrylic": false
  35. }
  36. ]
  37. }
  38. }

image.png

原文链接:https://blog.csdn.net/m0_47383991/article/details/106499585

image.png
image.png