cxw

CXBL

email
github

PowerShell美化

一,安裝 Nerd Font 字體#

避免出現字符 “▯”,Nerd Font 字體下載地址https://www.nerdfonts.com/font-downloads

二,安裝適用於 PowerShell 的 Oh My Posh#

1. 使用 winget 安裝#

winget install oh-my-posh

2. 使用 Microsoft Store 安裝#

3. 選擇並應用 PowerShell 主題#

notepad $PROFILE

填寫內容#

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\paradox.omp.json" | Invoke-Expression

主題官網:https://ohmyposh.dev/docs/themes

三,可能的問題#

1.notepad $PROFILE 可能會提示系統找不到指定的路徑,參考 Microsoft 文檔https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.3 中的 Profile types and locations 部分自行創建,然後重啟 Windows Terminal 即可。
#

2. 無法加載文件 ***\WindowsPowerShell\profile.ps1, 因為在此系統上禁止運行腳本#

查看現用執行策略

>> get-executionpolicy
Restricted

更改執行策略,以管理員身份打開 PowerShell

>> set-executionpolicy remotesigned

選擇 a 或者 y 選項,再次重啟 Windows Terminal。

本文連結源自https://learn.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup#

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。