Windows Terminal基础美化

可以安装PoweShell 7,也可以在默认的PoweShell环境中进行。

1、安装PSReadLine:

Install-Module -Name PSReadLine -AllowClobber -Force

2、安装posh-git:

Install-Module -Name posh-git -Force

3、安装on-my-posh:

winget install JanDeDobbeleer.OhMyPosh -s winget

4、配置PowerShell脚本运行权限:

Set-ExecutionPolicy RemoteSigned

5、创建配置文件:

notepad $Profile

导入上述模块:

Import-Module PSReadLine
Import-Module posh-git

6、配置PSReadLine,在配置文件中添加:

Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -MaximumHistoryCount 1024
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

7、配置posh-git,选项可在网络上搜索,此处略;

8、配置on-my-posh,在配置文件中添加:

oh-my-posh init pwsh | Invoke-Expression

若需要指定主题,则添加:

oh-my-posh init pwsh --config 'C:\Users\xxx\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json' | Invoke-Expression

9、保存关闭配置文件,重启Windows Terminal后生效。

10、字体设置:

on-my-posh工作基于Nerd系列字体,需要下载安装并选用,相关特殊字符方可正常显示。

Nerd Fonts - Iconic font aggregator, glyphs/icons collection, & fonts patcher

若对已经提供的字体不满意,可以使用提供的font-patcher脚本自行对已有字体进行patch,生成nerd字体,以Windows环境为例,具体方法如下:

1)下载FontForge并安装;

2)将已有待patch字体文件复制到font-patcher目录下;

3)打开FontForge interactive console,并切换到font-patcher目录下,运行命令:

ffpython .\font-patcher .\xxx.ttf -c

等待完成,即会在该目录下生成patch后的nerd字体文件,安装即可。

GitHub - ryanoasis/nerd-fonts: Iconic font aggregator, collection, & patcher. 3,600+ icons, 50+ patched fonts: Hack, Source Code Pro, more. Glyph collections: Font Awesome, Material Design Icons, Octicons, & more

  • 9
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值