How to Beef up Your Powershell 7 with Oh My Posh?

Abdullah Nafees
3 min readDec 30, 2021

--

My love for setting up a nice terminal, getting the prompt just right, setting my colours, fonts, etc. has gone to a new level ever since Windows Terminal came out. If you are a windows user and have craved a custom command prompt profile for your Powershell 7, you have come to the right place.

Windows Terminal is the default CMD application for Windows 11

Oh My Posh is a custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable. The resulting custom experience looks like this.

Look at the accents, it’s mesmerizing.

How to install Oh My Posh on Powershell 7?

First of all, I don’t mean Windows PowerShell (that’s “classic” now) I mean the .NET Core-powered cross-platform PowerShell. There’s a LOT of ways to get it but I’m a store person usually so I can get PowerShell (and it’ll auto-update) from the Microsoft Store or just “winget install Microsoft.PowerShell" from the command line with winget.

Note: In order for the prompt to display glyphs and symbols, you have to install any font of your choice from Nerd Fonts.

I like the DroidSanMono Nerd Font Mono so you can choose your own MONO font of choice and install it through your Windows settings. This is MODIFIED to include hundreds of special characters that you can use to make your prompt cooler. Now, go ahead and select the font of your choice in the Appearance tab of the Powershell profile in Windows Terminal settings.

To install Oh My Posh for Powershell 7, run the following command through Windows Terminal.

The PowerShell module only installs the Oh My Posh executable inside PowerShell, to use Oh My posh outside of PowerShell (bash, cmd, …), add the following folder to your $PATH

This installs a couple of things:

  • oh-my-posh.exe - Windows executable
  • themes - The latest Oh My Posh themes

For the $PATH to reload, a restart of your shell session is advised.

To update the module, run the following command.

As we installed Oh My Posh using Install-Module oh-my-posh, you need to first import Oh My Posh in your $PROFILE remembering at this point that oh-my-posh is an executable on the $PATH.

As the last command reloads your Powershell 7 instance, your prompt should look like this.

At this point, you’re good to go. The theme jandedobbeleer.omp.json displays the most common use-cases in your prompt, so 9/10 you'll be more than happy with it. However, if you want to explore additional functionality, going through the additional steps below will help you get started.

Change the theme

We downloaded all the themes and set jandedobbeleer.omp.json them as the one to use. However, there are a lot more to be discovered and maybe there are some you like better.

Enjoy! Thanks to the Windows Terminal Team and the always lovely Jan De Dobbeleer from Oh My Posh.

--

--