Skip to main content

Setting up Oh My Posh on Windows

This guide will walk you through replacing the default command line prompt with Oh My Posh. We will cover the setup for both the classic Command Prompt (CMD) and PowerShell, including fixing common issues.

info

While PowerShell supports Oh My Posh natively, the classic Command Prompt (cmd.exe) does not. To make it work in CMD, we will use a tool called Clink.

Step 1: Install a Nerd Font (Required)

Oh My Posh uses special icons and glyphs. If you don't install a Nerd Font, you will see placeholder boxes instead of symbols.

oh-my-posh font install

This will present a list of Nerd Font libraries, from which you can select Meslo, which includes the Meslo LGM NF font we recommend.

Step 2: Install Oh My Posh

Open your terminal and install Oh My Posh via winget:

winget install JanDeDobbeleer.OhMyPosh -s winget
Restart Required

After the installation finishes, restart your terminal so the oh-my-posh command is recognized in your system's PATH.


Clink injects advanced features into CMD, including persistent history and prompt theming.

Use the unique package ID to ensure you get the modern, maintained version:

winget install chrisant99.clink

Restart your terminal again after installation.

Run the following commands in your CMD:

clink config prompt use oh-my-posh
clink set ohmyposh.theme jandedobbeleer

If you see the clink does not start:

"C:\Program Files (x86)\clink\clink.bat" inject

If you want to integrate Clink permanently into your Windows startup or Command Prompt, a one-time setup is usually sufficient:

"C:\Program Files (x86)\clink\clink.bat" autorun install

Step 4: Setup for PowerShell

PowerShell does not require Clink. You can load Oh My Posh directly via your PowerShell Profile.

1. Edit your Profile

Open your profile in Notepad:

notepad $PROFILE

(If prompted to create the file, click Yes).

2. Add the Initialization Script

Add the following line to the end of the file to load a theme directly from the official repository (e.g., the cert theme):

oh-my-posh init pwsh --config "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/cert.omp.json" | Invoke-Expression

Save (Ctrl + S) and close Notepad.

3. Reload Profile

Apply the changes to your current session:

. $PROFILE

Fix: PSReadLine Errors (Spacebar, Enter, Ctrl+c)

If you receive Get-PSReadLineKeyHandler errors when reloading your profile, your PowerShell's PSReadLine module is outdated.

Solution A (Recommended): Update the module

Install-Module -Name PSReadLine -Force -SkipPublisherCheck -AllowClobber

Restart PowerShell after updating.

Solution B (Workaround): Disable Status/Keybindings Add the --no-status flag to your $PROFILE initialization line:

oh-my-posh init pwsh --config "..." --no-status | Invoke-Expression

Changing Themes & Preview

You can change your theme at any time.

  • Preview all themes: Run this command to see a live preview of every available theme rendered in your terminal:
    oh-my-posh print preview
  • Switch Themes (CMD):
    clink set ohmyposh.theme cert
  • Switch Themes (PowerShell): Update the URL in your $PROFILE to point to a different .omp.json file.

Command History

With Clink (CMD) and PSReadLine (PowerShell) installed, you now have a persistent command history across terminal restarts!

  • Reverse Search: Press Ctrl + R and start typing to search your history. Press Ctrl + R again to cycle through matches.
  • Auto-Suggestions: Press the Right Arrow key to complete a suggested command.

Troubleshooting

Clink does not start