Oh My Posh: PowerShell Font Scheme for Git Repositories
All articles from this blog can ONLY be redistributed on an Attribution-NonCommercial-NoDerivs basis. Please credit the source, thank you.
Twitter:@kelvinshen
Blog:Kelvin Shen's Blog
Introduction
In my old blog post, I showed you how to use Posh-git for PowerShell prompt customization. However, Posh-git is no longer the ideal tool for this, as it’s limited to PowerShell 5.x. Fortunately, we have a more modern and versatile alternative: Oh My Posh.
Oh My Posh is a powerful, cross-platform prompt theme engine that works seamlessly with both PowerShell 5.x and the newer PowerShell 7 (and beyond). It supports a collection of prompt themes, allowing you to work git repos with ease.
Prerequisites
- Windows Terminal: Ensure you have Windows Terminal installed. You can get it from the Microsoft Store.
- PowerShell 5.x
Installation Steps
winget install JanDeDobbeleer.OhMyPosh
notepad $PROFILE
# Create a new profile file if there is no existing one
new-item -type file -path $profile -force
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
Install-Module -Name Terminal-Icons -Repository PSGallery
PowerShell Appearance Settings
IMPORTANT: The Nerd Font didn’t work for me until I updated the Font face to the Nerd Font in PowerShell appearance settings
PowerShell 7+
Oh My Posh should also work for PowerShell 7+. To install PowerShell 7+ Open you exsiting PowerShell console and run the following command:
winget install --id Microsoft.Powershell
An unsolved problem
The Nerd font doesn’t work correctly in PowerShell 7+.