[Windows Terminal]配置文件

警告:此篇文章已经失去时效性,请酌情参考。


Windows Terminal的配置文件是一份json格式的文件,在Windows Terminal程序内可以通过快捷键Ctrl + ,快速打开。

配置文件结构

配置文件的基本结构如下。

{
    "globals": {
        "alwaysShowTabs": true,
        "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
        "initialCols": 120,
        "initialRows": 40,
        "keybindings": [
            {
                "command": "closeTab",
                "keys": [
                    "ctrl+w"
                ]
            }
        ],
        "requestedTheme": "system",
        "showTabsInTitlebar": true,
        "showTerminalTitleInTitlebar": true
    },
    "profiles": [
        {
            "acrylicOpacity": 0.75,
            "closeOnExit": true,
            "colorScheme": "Campbell",
            "commandline": "powershell.exe",
            "cursorColor": "#FFFFFF",
            "cursorShape": "bar",
            "fontFace": "Hack",
            "fontSize": 14,
            "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "historySize": 9001,
            "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
            "name": "Windows PowerShell",
            "padding": "0, 0, 0, 0",
            "snapOnInput": true,
            "startingDirectory": "%Workspaces%",
            "useAcrylic": true
        }
    ],
    "schemes": [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        }
    ]
}

globals属性设置了Windows Terminal的主要配置,如:默认使用的终端配置,使用的主题等。值得注意的是,defaultProfile使用GUID连接profiles的相关配置。profiles使用colorScheme属性连接schemes。详细释义如下。

属性释义说明
alwaysShowTabs始终显示标签
defaultProfile默认终端GUID,用于连接终端配置
initialCols默认列数
initialRows默认行数
keybindings快捷键配置
command快捷键执行的命令
keys快捷键
requestedTheme主题
showTabsInTitlebar在标题栏中显示终端窗口标签栏
showTerminalTitleInTitlebar在标签栏中显示终端标签
acrylicOpacity不透明度
closeOnExit退出后关闭
colorScheme颜色主题
commandline命令行程序
cursorColor光标颜色
cursorShape光标形状
fontFace字体
fontSize字体大小
guidGUID终端配置标识
historySize历史大小
icon图标
name名称
padding
snapOnInput嗅探输入
startingDirectory初始目录
useAcrylic使用不透明度

添加Git Bash

新终端配置需添加至profiles属性下。受Kubuntu影响,字体我喜欢使用Hack,Windows默认没有此字体,需切换为其他字体。guid需要自己生成一个新GUID,可以使用此网站在线生成GUID。启动命令使用Git\bin\bash.exe,切勿使用Git\git-bash.exe,会弹出新窗口。启动时的工作目录我就设置为我的代码存放目录,打开终端后即可直接执行git clone url,不必手动切换目录。因为多个软件经常使用此路径,我在用户变量中添加了Workspaces变量。
Workspaces环境变量
详细的配置如下。

{
    "acrylicOpacity" : 0.75,
    "closeOnExit" : true,
    "colorScheme" : "Campbell",
    "commandline" : "C:\\Program Files\\Git\\bin\\bash.exe",
    "cursorColor" : "#FFFFFF",
    "cursorShape" : "bar",
    "fontFace" : "Hack",
    "fontSize" : 14,
    "guid" : "{3afa95f7-eddc-4b45-bbbe-8eb6b3c09a80}",
    "historySize" : 9001,
    "icon" : "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
    "name" : "Git Bash",
    "padding" : "0, 0, 0, 0",
    "snapOnInput" : true,
    "startingDirectory" : "%Workspaces%",
    "useAcrylic" : true
}

添加SSH连接

SSH配置与其他配置基本一致,仅有commandline不同。因为安装Git的时候会自动安装SSH并加入到环境变量C:\Program Files\Git\usr\bin\ssh.exe。所以这里就直接写ssh.exe root@192.168.0.1进行连接。值得一提的是,因为我使用密钥验证,所以连接后自动登录,无需输入密码。密钥存放位置:C:\Users\Username\.ssh\id_rsa。另外我还下载了一个Ubuntu图标放在了这里C:\Users\Username\Documents\Icon\ubuntu.png

{
    "acrylicOpacity": 0.75,
    "closeOnExit": true,
    "colorScheme": "Campbell",
    "commandline": "ssh.exe root@192.168.0.1",
    "cursorColor": "#FFFFFF",
    "cursorShape": "bar",
    "fontFace": "Hack",
    "fontSize": 14,
    "guid": "{17801cde-1fe3-440a-95bf-4e3e0bf97e4d}",
    "historySize": 9001,
    "icon": "C:\\Users\\Username\\Documents\\Icon\\ubuntu.png",
    "name": "Linux Server",
    "padding": "0, 0, 0, 0",
    "snapOnInput": true,
    "useAcrylic": true
    // ...
}
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值