Skip to content

Instantly share code, notes, and snippets.

@fullmetalbrackets
Created July 13, 2023 07:34
Show Gist options
  • Save fullmetalbrackets/b2ba3968a08a572a7a3f371c8f6b07e0 to your computer and use it in GitHub Desktop.
Save fullmetalbrackets/b2ba3968a08a572a7a3f371c8f6b07e0 to your computer and use it in GitHub Desktop.
Quick Guide - Install Oh-My-Posh in Windows Terminal or PowerShell with winget

Pre-Requisites

This guide will use the winget CLI tool to install and configure Oh-My-Posh. If you haven't already, I suggest installing Windows Terminal from the Microsoft Store and use Oh-My-Posh with it. If you'd rather not use Windows Terminal for some reason, you can still use Oh-My-Posh with PowerShell. Whichever you choose, check out these instructions to install winget.


Install Oh-My-Posh

winget install JanDeDobbeleer.OhMyPosh -s winget

Open your PowerShell profile at C:\Users\<your-username>\Documents\Microsoft.PowerShell_profile.ps1 with your preferred text editor as an Administrator and add the following line to the top:

oh-my-posh init pwsh | Invoke-Expression

Save the changes and use the following command to reload your terminal:

. $PROFILE

You should now see the default theme of Oh-My-Posh. If you're satisfied with how it looks, we're done here. If you want to use a different theme, let's continue.


Use a theme with Oh-My-Posh

Most themes require a Nerd Font to properly display glyphs and symbols. Oh-My-Posh has a built-in CLI to pick out and install a Nerd Font

oh-my-posh font install and pick one, it will automatically be downloaded and installed. MesloLGM is the recommended font, but any of them will work.

Use the following command to preview how all the themes will look in the terminal. (Give it a minute, there's a lot of them.)

Get-PoshThemes

The themes are all located at C:\Users\<your-username>\AppData\Local\Programs\oh-my-posh\themes\. Lets assume you want to use the unicorn theme. Open Microsoft.PowerShell_profile.ps1 in your editor and change the init script to this:

oh-my-posh init pwsh --config 'C:\Users\<your-username>\AppData\Local\Programs\oh-my-posh\themes\unicorn.omp.json' | Invoke-Expression

And once again, reload your terminal with . $PROFILE. All done!


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 that I like.


Help! The icons in my theme are all squished together!

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 and it should fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment