安裝配置Oh My Posh

Tutorial: Set up a custom prompt for PowerShell or WSL with Oh My Posh

Install a Nerd Font

推薦Meslo 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
https://whoisryosuke.com/blog/2022/leveling-up-windows-powershell-with-oh-my-posh/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章