Customizing the Windows Terminal command prompt with Oh-My-Posh
While I use Zsh with Oh-My-Zsh for making my Linux terminal pretty, it's not available for Windows. Luckily it's brother from another mother Oh-My-Posh basically does the same thing for Windows Terminal and PowerShell.
Sections
- Pre-Requisites
- Installing WinGet and using it to install Oh-My-Posh
- Changing the theme
- Install a Nerd Font for themes that require it
- Additional non-bundled custom themes
- References
Pre-Requisites
You need to have PowerShell installed on Windows, and ideally you’ll want to use Windows Terminal as well. Follow the official Microsoft instructions to install PowerShell. For Windows Terminal, you’ll have to install it from the Windows Store.
The rest of this guide will assume you are using Windows Terminal.
Installing WinGet and using it to install Oh-My-Posh
If you have Windows 11 or Windows 10 Pro, you should already have the WinGet package manager installed, if not you’ll have to install App Installer which comes with WinGet.
We’ll be using WinGet in Windows Terminal to install Oh-My-Posh, as this is the official preferred method. Do so with this command:
winget install JanDeDobbeleer.OhMyPosh -s winget
Next we’ll make Oh-My-Posh the default shell, which requires editing your PowerShell profile. It should be located in at the following directory:
%userprofile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
If the the profile does not exist, create it with the command New-Item -Path $PROFILE -Type File -Force
. Edit the profile as an Administrator with the text editor of your choice. Add the following to the top:
oh-my-posh init pwsh | Invoke-Expression
Restart your terminal or reload the profile with the command . $PROFILE
for changes to take effect.
Changing the theme
Once you have installed Oh-My-Posh, the default theme will be used. Use the following command to list all the themes and get a preview of how they’ll look in the terminal. (Give it a minute, there’s a lot of them.)
Get Posh-Themes
The themes will all located in the following directory:
%userprofile%\AppData\Local\Programs\oh-my-posh\themes\
Let’s assume you decided to use the unicorn
theme (one of my favorites), you’ll have to edit your Microsoft.PowerShell_profile.ps1
and replace the init script with this:
oh-my-posh init pwsh --config '%userprofile%\AppData\Local\Programs\oh-my-posh\themes\unicorn.omp.json' | Invoke-Expression
Reload the terminal again with . $PROFILE
for the change to take effect.
Install a Nerd Font for themes that require it
You may notice that some themes cause weird missing icons in your prompt. This is because many of them require Nerd Fonts. Oh-My-Posh has a built-in CLI and pick out and install a Nerd Font. Any of them will work, but the official recommended font to use is MesloLGM.
Use the following command and pick out a font of your choice:
oh-my-posh font install
Next you’ll need to open Windows Terminal, go to Settings, and under Profiles click on Windows PowerShell, scroll down to Additional Settings and click Appearance, then change Font face to the Nerd Font you downloaded. Make sure to Save your changes.
To ensure the glyphs are correctly rendered, you’ll also want to go into Windows Terminal Settings, click on Rendering and switch on Use the new text renderer (“AtlasEngine”). If you’re noticing the symbols in some themes are not spaced properly and are right on top of text, be sure you do this step.
Custom themes not bundled with Oh-My-Posh
Oh-My-Posh comes with many themes that are regularly maintained, but anyone can create a custom theme. Here’s a few I’ve found on GitHub that I like.
- whoisryosuke’s custom theme (Requires
JetBrainsMono
Nerd Font) - Kudostoy0u’s pwsh10k theme (Requires
MesloLGS
Nerd Font) - adynetro’s custom theme (Requires
MesloLGM
Nerd Font) - Dofoerix’s custom themes (In several different colors and designs!)
- rainbowflesh’s cyborgone theme
- delacerate’s custom theme
- ryanewtaylor’s pride theme
- Darkensses’s cybershell theme
- drewyh999’s custom theme
- sclerp’s orangine theme
- SubsTheTechnomancer’s not-zork theme (I had to laugh at this one)
- leopoldo109’s custom theme
Related Articles
Quick guide to set up Zsh and Oh-My-Zsh with essential plugins and a theme