Windows Terminal 配置指南

目录

  • 配置文件框架
  • 启动Windows Terminal打开json文件
  • 修改Windows Terminal配置
    • 修改`"list":`里的终端配置
    • 在全局配置中加上默认窗口大小(宽和高)
    • 在全局配置中设置默认终端
    • 设置所有终端属性defaults
    • 添加配色方案
    • 完整配置文件
  • 字体推荐

前提:已经安装 Windows Terminal, 本文基于Microsoft Windows [Version 10.0.19044.1766]。

Windows Terminal是通过读取settings.json文件完成配置的, 如果配置文件书写格式不正确, 启动时会报错并且启用默认配置。建议: 操作前先备份settings.json文件, 以免配置错误引起不必要的麻烦, 文件路径:

C:\Users\用户名\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

配置文件框架

settings.json文件大概分成几部分, 都括在{ }里:

  1. "$schema": "https://aka.ms/terminal-profiles-schema",这行不用管
  2. "actions"用来设置快捷键, 可以自定义
  3. 类似"copyFormatting": "none",这样的写法没有用括号, 和"profiles":在同一级缩进, 是全局设置
  4. "profiles"用来配置不同的终端, "list"里是各种终端的配置
  5. "schemes"就是配色方案了, 自定义的配色方案可以放在这里
{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": 
    [
       //键盘快捷键...
    ],
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{默认启动的终端guid}",
    
    "profiles": 
    {
        "defaults": {},

        "list": 
        [
            {
        		//终端1配置
            },
            {
        		//终端2配置
            },            
        ]
    },
    "schemes": 
    [
        {
        	//配色方案1
        },
        {
        	//配色方案2
        },
    ],
}

启动Windows Terminal打开json文件

  1. 在标签页"+"号右侧点击下拉列表打开设置按钮

Windows Terminal 配置指南_第1张图片

  1. 在设置标签页左下角打开文件
    Windows Terminal 配置指南_第2张图片

修改Windows Terminal配置

修改"list":里的终端配置

Windows Terminal安装时会自动读取系统存在的终端并将其写入settings.json文件, 如果未识别也可以手动添加, 如手动添加msys2

            {
                "commandline": "C:/msys64/msys2_shell.cmd -defterm -no-start -use-full-path -here -mingw64",
                "guid": "{实际guid值}",
                "icon": "C:/msys64/msys2.ico",
                "name": "MSYS2",
            },

以上4条为基本的配置, 其中

  • “commandline” 表示msys2终端启动的命令行命令+参数
  • “guid” 用来标识该终端, 设置默认终端会用到, 手动添加终端时需要手动生成, 一种方案是使用在线生成器生成guid并复制粘贴到大括号中(这里给出一个在线生成guid工具链接: Online GUID / UUID Generator)
  • “icon” 表示在WIndows Terminal 里显示的图标
  • “name” 表示终端名

有更高配置要求的可以继续添加相应配置, 参数可以参考:

  • Windows Terminal: The Complete Guide
  • Windows 终端中的高级配置文件设置
  • Windows Terminal完整指南

在全局配置中加上默认窗口大小(宽和高)

    "initialCols": 88,
    "initialRows": 42,

Windows Terminal 配置指南_第3张图片

在全局配置中设置默认终端

"defaultProfile": "{填入要设置的终端的guid}",

Windows Terminal 配置指南_第4张图片

设置所有终端属性defaults

设置了defaults中的属性会在所有终端生效(如果需要不同终端不通配置, 可以选择在"list":的终端中配置)

        "defaults": 
        {
            "colorScheme": "iceberg-light",				//配色方案: iceberg-light
            "cursorColor": "#FD9D4F",					//光标颜色: 橙色
            "cursorShape": "filledBox",					//光标形状: 方块
            "experimental.retroTerminalEffect": false,  //复古终端效果: 否(可以设为true)
            "font": 									 //字体
            {
                "face": "Cascadia Code",
                "size": 13
            },
            "historySize": 20431,						 //历史条数
            "opacity": 85,								 //背景不透明度
            "useAcrylic": true							 //亚克力毛玻璃效果
        },

添加配色方案

关于配色有现成的配色方案网站选择:Windows Terminal Themes, 有N多配色方案, 开心就好!选择一个, 复制下来, 粘贴到"schemes":列表里, 如下:

Windows Terminal 配置指南_第5张图片

选自己喜欢的方案粘贴到"schemes":列表, 可以粘贴多种方案, 用{}括起来加,即可
Windows Terminal 配置指南_第6张图片

最后将该终端配置配色方案名称填到"colorScheme":
Windows Terminal 配置指南_第7张图片

完整配置文件

仅供参考, guid以自己电脑实际为准

未开启复古终端效果:

开启复古终端效果:

{
    "$help": "https://aka.ms/terminal-documentation",
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": 
    [
        {
            "command": "paste"
        },
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            }
        },
        {
            "command": "unbound",
            "keys": "ctrl+v"
        },
        {
            "command": "unbound",
            "keys": "ctrl+c"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ],
    "alwaysShowNotificationIcon": false,
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{}",
    "initialCols": 88,
    "initialRows": 42,
    "minimizeToNotificationArea": false,
    "profiles": 
    {
        "defaults": 
        {
            "bellStyle": "taskbar",
            "colorScheme": "iceberg-light",
            "cursorColor": "#FD9D4F",
            "cursorShape": "filledBox",
            "experimental.retroTerminalEffect": false,
            "font": 
            {
                "face": "Cascadia Code",
                "size": 13
            },
            "historySize": 20431,
            "opacity": 85,
            "useAcrylic": true
        },
        "list": 
        [
            {
                "commandline": "C:/msys64/msys2_shell.cmd -defterm -no-start -use-full-path -here -mingw64",
                "guid": "{实际guid值}",
                "icon": "C:/msys64/msys2.ico",
                "name": "MSYS2",
                "startingDirectory": "C:/Users/ryan"
            },
            {
                "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
                "guid": "{实际guid值}",
                "hidden": false,
                "name": "Windows PowerShell"
            },
            {
                "commandline": "%SystemRoot%\\System32\\cmd.exe",
                "guid": "{实际guid值}",
                "hidden": false,
                "name": "\u547d\u4ee4\u63d0\u793a\u7b26"
            },
            {
                "guid": "{实际guid值}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{实际guid值}",
                "hidden": false,
                "name": "Developer Command Prompt for VS 2017",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{实际guid值}",
                "hidden": false,
                "name": "Git Bash",
                "source": "Git"
            },
            {
                "background": "#350425",
                "commandline": "multipass shell",
                "cursorShape": "filledBox",
                "font": 
                {
                    "face": "Ubuntu Mono"
                },
                "guid": "{实际guid值}",
                "historySize": 50000,
                "icon": "C:/Program Files/Multipass/bin/multipass_wt.ico",
                "name": "Multipass"
            }
        ]
    },
    "schemes": 
    [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#012456",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell Powershell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#000000",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#FFFFFF",
            "green": "#13A10E",
            "name": "Color Scheme 10",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#1E1F29",
            "black": "#000000",
            "blue": "#BD93F9",
            "brightBlack": "#555555",
            "brightBlue": "#BD93F9",
            "brightCyan": "#8BE9FD",
            "brightGreen": "#50FA7B",
            "brightPurple": "#FF79C6",
            "brightRed": "#FF5555",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#F1FA8C",
            "cursorColor": "#BBBBBB",
            "cyan": "#8BE9FD",
            "foreground": "#F8F8F2",
            "green": "#50FA7B",
            "name": "Dracula",
            "purple": "#FF79C6",
            "red": "#FF5555",
            "selectionBackground": "#44475A",
            "white": "#BBBBBB",
            "yellow": "#F1FA8C"
        },
        {
            "background": "#5A5475",
            "black": "#040303",
            "blue": "#C2FFDF",
            "brightBlack": "#6090CB",
            "brightBlue": "#C2FFDF",
            "brightCyan": "#C5A3FF",
            "brightGreen": "#C2FFDF",
            "brightPurple": "#FFB8D1",
            "brightRed": "#FF857F",
            "brightWhite": "#F8F8F0",
            "brightYellow": "#FFEA00",
            "cursorColor": "#F8F8F0",
            "cyan": "#C5A3FF",
            "foreground": "#F8F8F2",
            "green": "#C2FFDF",
            "name": "Fairyfloss",
            "purple": "#FFB8D1",
            "red": "#F92672",
            "selectionBackground": "#8077A8",
            "white": "#F8F8F0",
            "yellow": "#E6C000"
        },
        {
            "background": "#202020",
            "black": "#000000",
            "blue": "#4581EB",
            "brightBlack": "#555555",
            "brightBlue": "#6D9DF1",
            "brightCyan": "#60D3D1",
            "brightGreen": "#67FF4F",
            "brightPurple": "#FB82FF",
            "brightRed": "#FB7172",
            "brightWhite": "#EEEEEE",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#33C2C1",
            "foreground": "#ADADAD",
            "green": "#126E00",
            "name": "JetBrains Darcula",
            "purple": "#FA54FF",
            "red": "#FA5355",
            "selectionBackground": "#FFFFFF",
            "white": "#ADADAD",
            "yellow": "#C2C300"
        },
        {
            "background": "#EAEAEA",
            "black": "#212121",
            "blue": "#134EB2",
            "brightBlack": "#424242",
            "brightBlue": "#54A4F3",
            "brightCyan": "#26BBD1",
            "brightGreen": "#7ABA3A",
            "brightPurple": "#AA4DBC",
            "brightRed": "#E83B3F",
            "brightWhite": "#D9D9D9",
            "brightYellow": "#FFEA2E",
            "cursorColor": "#FFFFFF",
            "cyan": "#0E717C",
            "foreground": "#232322",
            "green": "#457B24",
            "name": "Material",
            "purple": "#560088",
            "red": "#B7141F",
            "selectionBackground": "#FFFFFF",
            "white": "#EFEFEF",
            "yellow": "#F6981E"
        },
        {
            "background": "#282C34",
            "black": "#282C34",
            "blue": "#61AFEF",
            "brightBlack": "#5A6374",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B6C2",
            "brightGreen": "#98C379",
            "brightPurple": "#C678DD",
            "brightRed": "#E06C75",
            "brightWhite": "#DCDFE4",
            "brightYellow": "#E5C07B",
            "cursorColor": "#FFFFFF",
            "cyan": "#56B6C2",
            "foreground": "#DCDFE4",
            "green": "#98C379",
            "name": "One Half Dark",
            "purple": "#C678DD",
            "red": "#E06C75",
            "selectionBackground": "#FFFFFF",
            "white": "#DCDFE4",
            "yellow": "#E5C07B"
        },
        {
            "background": "#FAFAFA",
            "black": "#383A42",
            "blue": "#0184BC",
            "brightBlack": "#4F525D",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B5C1",
            "brightGreen": "#98C379",
            "brightPurple": "#C577DD",
            "brightRed": "#DF6C75",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#E4C07A",
            "cursorColor": "#4F525D",
            "cyan": "#0997B3",
            "foreground": "#383A42",
            "green": "#50A14F",
            "name": "One Half Light",
            "purple": "#A626A4",
            "red": "#E45649",
            "selectionBackground": "#FFFFFF",
            "white": "#FAFAFA",
            "yellow": "#C18301"
        },
        {
            "background": "#002B36",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#FFFFFF",
            "cyan": "#2AA198",
            "foreground": "#839496",
            "green": "#859900",
            "name": "Solarized Dark",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#FDF6E3",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#002B36",
            "cyan": "#2AA198",
            "foreground": "#657B83",
            "green": "#859900",
            "name": "Solarized Light",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#D3D7CF",
            "green": "#4E9A06",
            "name": "Tango Dark",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#FFFFFF",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#000000",
            "cyan": "#06989A",
            "foreground": "#555753",
            "green": "#4E9A06",
            "name": "Tango Light",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#300A24",
            "black": "#2E3436",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#EEEEEC",
            "green": "#4E9A06",
            "name": "Ubuntu",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#000080",
            "brightBlack": "#808080",
            "brightBlue": "#0000FF",
            "brightCyan": "#00FFFF",
            "brightGreen": "#00FF00",
            "brightPurple": "#FF00FF",
            "brightRed": "#FF0000",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#008080",
            "foreground": "#C0C0C0",
            "green": "#008000",
            "name": "Vintage",
            "purple": "#800080",
            "red": "#800000",
            "selectionBackground": "#FFFFFF",
            "white": "#C0C0C0",
            "yellow": "#808000"
        },
        {
            "background": "#FCF4DC",
            "black": "#56595C",
            "blue": "#2E8BCE",
            "brightBlack": "#45484B",
            "brightBlue": "#2176C7",
            "brightCyan": "#259286",
            "brightGreen": "#738A04",
            "brightPurple": "#C61C6F",
            "brightRed": "#BD3613",
            "brightWhite": "#C9C6BD",
            "brightYellow": "#A57705",
            "cursorColor": "#536870",
            "cyan": "#32A198",
            "foreground": "#536870",
            "green": "#85981C",
            "name": "Violet Light",
            "purple": "#D13A82",
            "red": "#C94C22",
            "selectionBackground": "#595AB7",
            "white": "#D3D0C9",
            "yellow": "#B4881D"
        },
        {
            "background": "#E8E9EC",
            "black": "#DCDFE7",
            "blue": "#2D539E",
            "brightBlack": "#8389A3",
            "brightBlue": "#22478E",
            "brightCyan": "#327698",
            "brightGreen": "#598030",
            "brightPurple": "#6845AD",
            "brightRed": "#CC3768",
            "brightWhite": "#262A3F",
            "brightYellow": "#B6662D",
            "cursorColor": "#33374C",
            "cyan": "#3F83A6",
            "foreground": "#33374C",
            "green": "#668E3D",
            "name": "iceberg-light",
            "purple": "#7759B4",
            "red": "#CC517A",
            "selectionBackground": "#33374C",
            "white": "#33374C",
            "yellow": "#C57339"
        },
        {
            "background": "#2E3440",
            "black": "#3B4252",
            "blue": "#81A1C1",
            "brightBlack": "#4C566A",
            "brightBlue": "#81A1C1",
            "brightCyan": "#8FBCBB",
            "brightGreen": "#A3BE8C",
            "brightPurple": "#B48EAD",
            "brightRed": "#BF616A",
            "brightWhite": "#ECEFF4",
            "brightYellow": "#EBCB8B",
            "cursorColor": "#FFFFFF",
            "cyan": "#88C0D0",
            "foreground": "#D8DEE9",
            "green": "#A3BE8C",
            "name": "nord",
            "purple": "#B48EAD",
            "red": "#BF616A",
            "selectionBackground": "#FFFFFF",
            "white": "#E5E9F0",
            "yellow": "#EBCB8B"
        }
    ]
}

字体推荐

三款字体都支持开启连字, 可以都试试

  1. Jet Brains系列
    Windows Terminal 配置指南_第8张图片

Windows Terminal 配置指南_第9张图片

  1. Cascadia Code
    Windows Terminal 配置指南_第10张图片

  2. FiraCode
    Windows Terminal 配置指南_第11张图片

你可能感兴趣的:(软件工具,windows,windows,terminal)