Tutorial: Set up a custom prompt for PowerShell or WSL with Oh My Posh
Install a Nerd Font
安装完成后打开Windows Terminal然后按"Ctrl+Shift+,(逗号)"来打开settings.json配置文件
"profiles": {
"defaults": {
"font": {
"face": "MesloLGS NF"
}
},
Customize your PowerShell prompt with Oh My Posh
Install Oh My Posh for PowerShell
winget install oh-my-posh
This will install:
oh-my-posh.exe: The Windows executable
themes: The latest Oh My Posh themes
winget install XP8K0HKJFRXGCK
Choose and apply a PowerShell prompt theme
Choose a theme and update your PowerShell profile with this command. (You can replace notepad with the text editor of your choice.)
notepad $PROFILE
PS:The $PROFILE variable
Current User, Current Host - $PROFILE
$PROFILE | Get-Member -Type NoteProperty
it should be ""C:\Users{username}\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1""
Add the following to the end of your PowerShell profile file to set the paradox
theme. (Replace paradox
with the theme of your choice.)
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\paradox.omp.json" | Invoke-Expression
Use Terminal-Icons to add missing folder or file icons
To install Terminal-Icons with PowerShell, use the command:
Install-Module -Name Terminal-Icons -Repository PSGallery
参考
https://zhuanlan.zhihu.com/p/354603010
https://learn.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup