安装PowerShell 7

下载地址: 官方GitHub

下载后安装即可

安装OhMyPosh

1
winget install JanDeDobbeleer.OhMyPosh -s winget

配置OhMyPosh

下载主题

  • 主题下载地址

  • 把主题下载到一个指定位置, 记住这个位置, 后面要调用

1
2
3
4
5
6
7
8
9
10
# 下载easy-term主题 
Invoke-WebRequest -Uri "https://wget.la/https://github.com/JanDeDobbeleer/oh-my-posh/raw/main/themes/easy-term.omp.json" -OutFile "D:\[个人文件夹]\PowerShell 7\Themes\easy-term.omp.json"

Invoke-WebRequest -Uri "https://wget.la/https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/themes/cert.omp.json" -OutFile "D:\[个人文件夹]\PowerShell 7\Themes\cert.omp.json"

Invoke-WebRequest -Uri "https://wget.la/https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/themes/craver.omp.json" -OutFile "D:\[个人文件夹]\PowerShell 7\Themes\craver.omp.json"

Invoke-WebRequest -Uri "https://wget.la/https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/themes/blueish.omp.json" -OutFile "D:\[个人文件夹]\PowerShell 7\Themes\blueish.omp.json"

Invoke-WebRequest -Uri "https://wget.la/https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/themes/atomic.omp.json" -OutFile "D:\[个人文件夹]\PowerShell 7\Themes\atomic.omp.json"

下载字体

1
2
3
4
# 这里主要下载Meslo字体
oh-my-posh font install meslo

# 也可以github下载, 下载地址https://github.com/ryanoasis/nerd-fonts/releases, 下载后全选右键安装即可

配置字体

打开终端(PowerShell 7): CTRL + SHIFT + , 打开配置文件, 主要替换defaults字段

1
2
3
4
5
6
7
8
9
10
11
12
{
"profiles":
{
"defaults":
{
"font":
{
"face": "MesloLGM Nerd Font"
}
}
}
}

配置主题

1
2
3
4
5
6
7
8
# 打开终端配置文件
notepad $PROFILE

# 如果不存在, 创建配置文件
New-Item -Path $PROFILE -Type File -Force

# PS:查看默认终端
oh-my-posh get shell

在配置文件中加入

1
oh-my-posh init pwsh --config "D:\[个人文件夹]\PowerShell 7\Themes\easy-term.omp.json" | Invoke-Expression

引用的主题就是前面下载的主题

重新打开一个PowerShell 7, 即可看到效果