给“黑长直”的Windows Terminal 整个容吧
效果
怎么样,这不比默认的”傻黑粗“来的赏心悦目
开始
废话不多说,开始我们的自定义powerShell之旅
window默认的powershell由"傻黑粗"进化为"傻大蓝",丑也是真的丑,所以我一直用的都是cmder
去处理命令行,知道今天我在摸鱼的时候发现了
Windows Terminal,
抱着试一试的心态获取了它,咳咳,结果还是蛮失望的,一如既往的微软风格,但是这是开源的,也就意味着可以修改它的配置,
而它的配置文件存储在
❝
~AppDataLocalPackagesMicrosoft.WindowsTerminal_8wekyb3d8bbweLocalStatesetting.json
❞
这个文件中,稍后我会简单介绍一下里面的常用配置。
改造PowerShell
效果图中的路径效果是需要额外的包去美化的,这里我们需要先安装oh-my-posh,在PowerShell中输入
Install-Module posh-git -Scope CurrentUserInstall-Module oh-my-posh -Scope CurrentUser
遇到让你允许不可信来源的时候直接敲A
全部信任。
安装完成后输入
Import-Module posh-gitImport-Module oh-my-posh
Set-Theme PowerLine
你会发现PowerShell变了样子,但是重启后就消失了,因为这些指令仅限于此次会话,所以我们要将这几句命令添加到启动脚本中。
打开~DocumentsWindowsPowerShell
,新建文本文档,叫做Microsoft.PowerShell_profile.ps1
(记得开拓展名显示),输入以下内容,保存。
Import-Module posh-gitImport-Module oh-my-posh
Set-Theme PowerLine
这样,在每次PoweShell打开的时候都能启用PowerLine主题。
可是这样,PowerShell打开的时候仍有乱码(或者说,有违和感),这是因为没有给你使用的字体链接表情,乱码的地方其实就是表情符号。
字体选择
现在Powershell中会有乱码,是因为我们的字体无法显示,所以我们需要安装指定字体,我这里选用的是Sarasa Term SC
(
点此下载
),
这个字体是等宽字体,不会在终端中出现排版错误,下载安装后我们在注册表中配置,我这里直接提供一个reg脚本,把下面的片段复制到一个reg文件中,双击自动导入:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionFontLinkSystemLink]
"Sarasa Term SC"=hex(7):4d,00,49,00,43,00,52,00,4f,00,53,00,53,00,2e,00,54,00,
54,00,46,00,2c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,20,
00,53,00,61,00,6e,00,73,00,20,00,53,00,65,00,72,00,69,00,66,00,2c,00,31,00,
30,00,38,00,2c,00,31,00,32,00,32,00,00,00,4d,00,49,00,43,00,52,00,4f,00,53,
00,53,00,2e,00,54,00,54,00,46,00,2c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,
6f,00,66,00,74,00,20,00,53,00,61,00,6e,00,73,00,20,00,53,00,65,00,72,00,69,
00,66,00,00,00,4d,00,49,00,4e,00,47,00,4c,00,49,00,55,00,2e,00,54,00,54,00,
43,00,2c,00,50,00,4d,00,69,00,6e,00,67,00,4c,00,69,00,55,00,00,00,4d,00,53,
00,4d,00,49,00,4e,00,43,00,48,00,4f,00,2e,00,54,00,54,00,43,00,2c,00,4d,00,
53,00,20,00,50,00,4d,00,69,00,6e,00,63,00,68,00,6f,00,00,00,42,00,41,00,54,
00,41,00,4e,00,47,00,2e,00,54,00,54,00,43,00,2c,00,42,00,61,00,74,00,61,00,
6e,00,67,00,00,00,4d,00,53,00,59,00,48,00,2e,00,54,00,54,00,43,00,2c,00,4d,
00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,20,00,59,00,61,00,48,00,
65,00,69,00,20,00,55,00,49,00,00,00,4d,00,53,00,4a,00,48,00,2e,00,54,00,54,
00,43,00,2c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,20,00,
4a,00,68,00,65,00,6e,00,67,00,48,00,65,00,69,00,20,00,55,00,49,00,00,00,59,
00,55,00,47,00,4f,00,54,00,48,00,4d,00,2e,00,54,00,54,00,43,00,2c,00,59,00,
75,00,20,00,47,00,6f,00,74,00,68,00,69,00,63,00,20,00,55,00,49,00,00,00,4d,
00,41,00,4c,00,47,00,55,00,4e,00,2e,00,54,00,54,00,46,00,2c,00,4d,00,61,00,
6c,00,67,00,75,00,6e,00,20,00,47,00,6f,00,74,00,68,00,69,00,63,00,00,00,53,
00,45,00,47,00,55,00,49,00,53,00,59,00,4d,00,2e,00,54,00,54,00,46,00,2c,00,
53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,20,00,53,00,79,00,6d,00,62,
00,6f,00,6c,00,00,00,00,00
settings
准备工作做完了,现在介绍一下PowerShell的配置文件,
"profiles": {"defaults": {
// Put settings here that you want to apply to all profiles.
"backgroundImage": "C:\Users\MileWang\Pictures\桌面\wallhaven-j5lx3y.jpg",
// # 背景图透明度
"backgroundImageOpacity": 0.6,
// # 背景图扩展模式
"backgroundImageStretchMode": "fill",
// # 颜色主题,主题在下方shceme中添加
"colorScheme": "3024 Day",
// # 光标样式、颜色
"cursorShape": "vintage",
"cursorColor": "#000",
// # 字体
"fontFace": "Sarasa Term SC",
},
"list": [{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "命令提示符",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
]
},
一些简单的配置已经注释在代码中,其中主题Scheme可以在atomcorp.github.io/themes/
中选择你想要的配色。选择后添加到json文件的scheme数组中,然后在上方profiles
选择想要使用的终端,添加。我这里因为windows主要使用PowerShell,所以直接将设置都加在default
默认中了,宁可以在List
中选择想要配置的终端。
结束
不管怎么说,windows终于结束了难看的终端界面,而且这个终端还是开源的。所以有很大的可玩性,希望各位大佬能够玩出花来。
好了我继续去用cmder了……
本文使用 mdnice 排版
以上是 给“黑长直”的Windows Terminal 整个容吧 的全部内容, 来源链接: utcz.com/a/31760.html