美化 Windows Terminal

发布时间 2023-10-08 17:29:49作者: 灵火

安装 Scoop

scoop 官网:https://scoop.sh/

使用管理员打开 powershell,写入以下命令进行安装

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm get.scoop.sh | iex -RunAsAdmin

安装 Windows Terminal

scoop bucket add extras
scoop install extras/windows-terminal

安装 Oh-My-Posh

oh-my-posh 官网:https://ohmyposh.dev/docs/

1. 开始安装

scoop install oh-my-posh

2. 查看安装情况

获取安装路径(然后添加到安全软件白名单):
(Get-Command oh-my-posh).Source

查看主题存放目录
echo $env:POSH_THEMES_PATH

主题存放地址:%USERPROFILE%\AppData\Local\Programs\oh-my-posh\themes
image

3. 查看主题

Get-PoshThemes

也可以去官网查看:https://ohmyposh.dev/docs/themes
image

4. 设置主题

使用此命令将主题写入配置,之后启用终端都会生效:

'oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" | Invoke-Expression' > $PROFILE
image

5. 修改主题

想改主题也很简单,主题文件名jandedobbeleer.omp.json 改 'jandedobbeleer' 为你想要的主题名字,比如 'aliens',最后重启终端 或 使用此命令 . $PROFILE 重新加载配置。

示例(修改主题为 aliens):
'oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\aliens.omp.json" | Invoke-Expression' > $PROFILE; . $PROFILE

6. 设置字体

如果出现乱码,则需要对终端设置 nerd-fonts 字体:
image

安装字体 oh-my-posh font install
image

对 windows terminal 设置字体,记得 Save:
image