Windows Terminal with Oh My Posh
I spend a considerable amount of my time in the terminal, a large portion of that doing things with version control. As such I find it handy to have as much information available at a glance. On Ubuntu and MacOS I use Oh My Zsh, a great plugin to extend and customise your terminal but what happens when I’m working on Windows?
Thanks to Oh My Posh we can customise our Windows Terminal to have similar extensibility and customisation.
I’ve gone through the hassle of putting it all together and documenting it below if you’re interested in having a setup that looks similar to mine:
Step 1 - Get the new PowerShell
This confounded me for a while because I was struggling with the legacy PowerShell that ships with Windows. Turns out there’s a new and improved, .Net Core-powered PowerShell available.
Before we can move ahead we need to grab it, you can either grab it on the Microsoft Store (it’s free) or use winget install Microsoft.PowerShell
.
Step 2 - Get Windows Terminal
If you’re on Windows 11, you probably already have Windows Terminal installed. If you don’t, you can grab it from the Microsoft Store (also free) or use winget install Microsoft.WindowsTerminal
.
Once that’s done, go ahead and fire it up, you should be confronted with the legacy version of PowerShell but if you hit the dropdown on the tab drawer you’ll see a list of available shells.
Terminal should already have picked up that you have PowerShell installed (the one at the bottom) but you’ll still have Windows PowerShell set as your default. You can change the default (Highly recommended) in the lovely settings UI that ships with Terminal.
If you have WSL and other shells installed, they should also show up in the dropdown or you might simply need to add them.
Step 3 - Install a Nerd Font
This might be new to some but if you, like me, enjoy having ligatures in your code, you’ve probably come across some of them like Fira Code or Monoid.
A great place to find some good ones is nerdfonts.com go and pick one you like and install it. It’s a personal preference really, some fonts might be missing some glyphs as well so keep that in mind.
I’ve always loved Fira Code but it seems to miss some glyphs, Oh My Posh recommends Meslo LGM NF.
Once you have it installed, head to your terminal settings and select that as the font to use. Fonts are set on a per-shell basis, make sure to scroll down all the way to find PowerShell specific settings.
Step 4 - Install Oh My Posh
I highly recommend following the installation instructions on the Oh My Posh website as it might change or get updated. I will however regurgitate the basic instructions here:
1 - Install Oh-My-Posh by running winget install JanDeDobbeleer.OhMyPosh -s winget
.
2 - Restart your terminal, to make sure PATH gets reloaded.
3 - Edit your $PROFILE using notepad $PROFILE
if that fails due to the file not being found, run New-Item -Path $PROFILE -Type File -Force
first, this will add the file to your PATH.
4 - Add the following line to the file oh-my-posh init pwsh | Invoke-Expression
save and close the file.
5 - Reload your profile for the changes to take effect with . $PROFILE
.
That’s it! You should immediately be greeted with a new colourful command line.
Further steps
There is a lot of configuration you can do to customise this to your own liking. I might write another post detailing that but for now, you can always go browse the themes to find something to your liking or go read more about segments and how you can customise Oh My Posh to be more specific to the technologies you work with on a day-to-day basis.