1.下载配置oh-my-posh
# 下载oh-my-posh
winget install JanDeDobbeleer.OhMyPosh -s winget
# 配置oh-my-posh的环境变量
$env:Path += ";C:\Users\user\AppData\Local\Programs\oh-my-posh\bin"
2.创建oh-my-posh的配置文件
# 检查 $PROFILE 文件是否存在, 如果不存在则新建空文件
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
# 打开配置文件
notepad $PROFILE
3.配置oh-my-posh的配置文件
# 写入配置文件的内容
oh-my-posh init pwsh --config $env:POSH_THEMES_PATH\bubbles.omp.json | Invoke-Expression
4.配置oh-my-posh的主题
- windows上的配置文件中主题文件的位置:
C:\Users\<UserName>\AppData\Local\Programs\oh-my-posh\themes
-
选择你喜欢的主题,通过第三步修改主题的名字
例如:
oh-my-posh init pwsh --config $env:POSH_THEMES_PATH\M365Princess.omp.json | Invoke-Expression
5.问题与解决方案
- XXX 在此系统上禁止运行脚本
输入:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned