Skip to content

Instantly share code, notes, and snippets.

@martijnvanschie
Last active June 8, 2023 08:23
Show Gist options
  • Save martijnvanschie/aa4cbd21f69c659b0269e22bc1537c39 to your computer and use it in GitHub Desktop.
Save martijnvanschie/aa4cbd21f69c659b0269e22bc1537c39 to your computer and use it in GitHub Desktop.
Oh My Posh Quick Guide

Oh My Posh - Quick Guide

Installing on windows 11

You can install oh-my-posh per terminal but you can also use winget for the easiest installation. It will apply to all available terminals on your system.

Open a PowerShell prompt and run the following command:

winget install oh-my-posh

Init Oh My Posh for Powershell

You can initialize OMP manually via the terminal or have the terminal init OMP atomically using your Profile script.

Manual init

Run the following command in the terminal to start it manually

oh-my-posh init pwsh | Invoke-Expression

Automatic init

Run the following command to open your profle script

notepad $PROFILE

Then add the following init line

oh-my-posh init pwsh | Invoke-Expression

Theming

Oh My Posh comes with a default theme. The following command will display all themes in the current path and download them to your local profile location.

Get-PoshThemes

This is very convenient as it shows you what the current path looks like for each theme and you also have the local copy to use in your profile init script.

Themes location: C:\Users\{YOURNAME}\AppData\Local\Programs\oh-my-posh\themes

To change your theme, adjust the init script in C:\Users\{YOURNAME}\Documents\PowerShell\Microsoft.PowerShell_profile.ps1.
Example:
  oh-my-posh init pwsh --config C:\Users\{YOURNAME}\AppData\Local\Programs\oh-my-posh\themes/jandedobbeleer.omp.json | Invoke-Expression

Now choose one, open your init script again and add the --config line with the correct theme config to the script

oh-my-posh init pwsh --config C:\Users\{YOPURNAME}\AppData\Local\Programs\oh-my-posh\themes/jandedobbeleer.omp.json | Invoke-Expression

Fonts

Most themes use some icons to display location info, git status or Azure information. This is done using the common font Nerd Font.

The fonts can be easily installed using the OMP CLI.

Run the following command to install your favorite face from the Nerd Font collection. OMG recommends Meslo LGM NF so we will use that in the example.

oh-my-posh font install

Scroll down to the font with name Meslo and install the font. After a restart of the terminal you need to set the font in the settings.

  1. Open (or restart) your windonws terminal and open the settings.
  2. Either configure the font global (default) of per terminal.
  3. Select the font 'MesloLGM Nerd Fonts' as your font.
  4. The changes should reflect you new font.

Resources

Set up your terminal on Windows

Themes

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