Windows Terminal 使用技巧

点击这里,边看视频讲解,边学习以下内容

目前(2023),Windows下面缺省的终端程序叫 Windows Console Host, 对应的执行程序是 conhost.exe。

conhost.exe 比较古老,微软推出了新的终端叫 Windows Terminal。

相比之下,它支持多tab页,分区,更多的颜色,Unicode字符,呈现视觉效果要好很多。

安装

Windows 11 已经内置了 Windows Terminal。

如果是 Windows 10 ,可以直接在 应用商店 里面安装。

设定缺省shell

先找到 "profiles" 配置项,看里面 cmd.exe 对应的 guid 是什么,拷贝 cmd.exe 对应的 guid 到 "defaultProfile" 中

设定选中即复制

修改 "copyOnSelect" 选项的值为 true ,如下所示

"copyOnSelect": true,

设定配色

请将下面的配色方案拷贝到 "schemes" 配置项数组中,使 "schemes" 从空数组,变成下面的结果

  "schemes": [      
    {
      "name": "Campbell",

      "cursorColor": "#FFFFFF",
      "selectionBackground": "#ffffff",

      "background": "#063d3a",
      "foreground": "#ece4e4",

      "black": "#0C0C0C",
      "blue": "#0037DA",
      "cyan": "#3A96DD",
      "green": "#13A10E",
      "purple": "#881798",
      "red": "#C50F1F",
      "white": "#CCCCCC",
      "yellow": "#C19C00",
      "brightBlack": "#767676",
      "brightBlue": "#3B78FF",
      "brightCyan": "#61D6D6",
      "brightGreen": "#16C60C",
      "brightPurple": "#B4009E",
      "brightRed": "#E74856",
      "brightWhite": "#F2F2F2",
      "brightYellow": "#F9F1A5"
    }
  ],

然后在一个可以调色的文本编辑器中打开设置文件 settings.json ,直观的调整为你喜欢的颜色。

大家注意到这个配色方案的名字 为 Campbell, 这是profile 使用 缺省 的配色方案名。

只要 profile中不明确指定 colorScheme 设置,那么 colorScheme 设置就是 Campbell。

设定字体

在你使用的profile中加入如下配置即可

        "fontFace" : "Consolas",
        "fontSize" : 12,

fontFace 是字体名, 比如 Consolas、NSimsun、SimHei、Consolas,必须是本机能找到的字体文件。

fontSize 是字体大小