忆往昔岁月,不堪回首,伟大的 Windows 竟然拿不出一个像样的终端模拟器。mintty.exe 和 封装后的 cmder 之流,总是有各种问题,而且不兼容 emoji 字符。后来,全网 Windows 用户随着一个华丽的广告沸腾了,微软宣布了终端软件 Windows Terminal 的开发进程,而且开源!如今,Windows Terminal 预览版已经陪伴我们走过了挺长一段时间,其稳定性和易用性已经非常不错,关键是颜值相当高。如果你是一个追求完美的人,那么请跟上我的步伐,让我们扬帆起航!
> 安装 Windows Terminal 也可以直接去 Microsoft Store 搜索下载。
如果在之前已经安装过了的话,升级之后,配置文件还是老版本的配置文件的样子,这样导致一个问题就是会有一个额外的标题栏,于是打开就会出现有两个标题栏的丑东西。解决的办法也比较简单,把配置文件换成新的配置文件的样子就可以了:
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles":
[
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"useAcrylic": true,
"cursorShape": "filledBox",
"scrollbarState": "hidden"
},
{
// Make changes here to the cmd.exe profile
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "cmd",
"commandline": "CMD",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
],
// Add custom color schemes to this array
"schemes": [],
// Add any keybinding overrides to this array.
// To unbind a default keybinding, set the command to "unbound"
"keybindings": []
}
这么个刚需的东西现在竟然需要手动配置,有点不太友好。实现的原理也很简单, 就是在注册表中写入一条右键菜单配置,为了美观一点,我们给它加上一个图标:
Local
目录下新建个子目录, 如: C:\Users\[用户名]\AppData\Local\terminal
aa.reg
文件, 命名随意,路径替换,双击运行。Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Terminal here"
"Icon"="C:\\Users\\[用户名]\\AppData\\Local\\terminal\\terminal.ico"
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\[用户名]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"
profile
配置下都加上这么一行:"startingDirectory": "./"
原生主题 FFF 字色有点晃眼,此时自己可以定义一套 Schema
来自定义主题。具体的做法就是在 Schema
数组中添加一个对象,配置好对应的颜色,然后在想要使用主题的 Profile
对象中指定 colorScheme
就可以了。最后的配置放在最后。
这两个属性设置也是在 Profile
中设置,现在的设置也很简单:
"useAcrylic": true, // 打开透明效果
"acrylicOpacity": 0.8, // 背景透明度
"backgroundImage": "E:\\Images\\wallpaper\\1.jpg", // 背景图片效果
"backgroundImageOpacity": 0.3, // 背景图片透明度
设置 SSH 远程连接也是一样,通过添加一个 Profile
就可以完成。具体做法是,添加一个新的 Profile
,设置基本属性后,添加一条 commonLine
的属性,如:
"commonLine": "ssh someone@123.231.132.123`
为了省去输入密码的步骤,可以将 ssh
公钥上传至对应的服务器中,比如对应上面这条配置,具体做法如下:
123.231.132.123
机器上面 /home/someone/.ssh/authorized_keys
文件,如果没有,则依次创建;C:\Users\[用户名]\.ssh\id_rsa.pub
到上面创建的文件中;如果电脑安装了 Git,可以将 GitBash 集成到 Terminal 中,体验效果炫酷且无缝切换的客户端。具体的方法就是配置一个新的 Profile
,需要注意的是, 执行文件的路径,不是 Git 安装目录下的 git-bash.exe
,而是 bin/bash.exe
,然后再找个合适的图标就好了,下载图标文件。
{
"guid": "{714caed7-ef94-468e-b73c-797c4b064fa6}",
"name": "Git",
"icon": "C:\\Program Files\\Git\\git.png",
"commandline": "C:\\Program Files\\Git\\bin\\bash.exe"
}
如果 Windows 安装了 WSL,会自动配置一个对应操作系统的 Profile
,如果没有的话,也可以自己配置,大概内容如下:
{
"guid": "{98580abb-df41-5a69-97cc-d558b1e5c68a}",
"name": "centos8",
"source": "Windows.Terminal.Wsl"
}
全部搞定,是不是很 Nice!
最终效果图,如下:
附上配置文件:
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command": "paste",
"keys": "ctrl+v"
},
{
"command":
{
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
}
],
"copyFormatting": "none",
"copyOnSelect": false,
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"profiles":
{
"defaults": {},
"list":
[
{
"commandline": "powershell.exe",
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": false,
"name": "Windows PowerShell"
},
{
"commandline": "cmd.exe",
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": false,
"name": "\u547d\u4ee4\u63d0\u793a\u7b26"
},
{
"acrylicOpacity": 0.0,
"backgroundImage": "C:\\Users\\Jin\\Desktop\\images\\\u98ce\u666f\\\u6cd5\u56fd-\u57c3\u83f2\u5c14\u94c1\u5854.jpg",
"backgroundImageOpacity": 0.19,
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell",
"padding": "10",
"source": "Windows.Terminal.PowershellCore",
"useAcrylic": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
]
},
"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": "#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": "#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"
}
],
"theme": "system"
}