How to Activate Oh My Posh Git Prompt in Your Terminal & in Your IDE

Oh My Posh is a great extension to show a useful Git prompt in your terminal. It actually works on Windows, even if we need some extra steps to turn this prompt

The usual prompt in Windows Terminal

into this

We now see what branch we are on and if there is uncommited work in our Git repository

 

Installation

We can use the official installation guide an install Oh My Posh from the Windows Store:

You can find Oh My Posh in the Windows Store

This installer gets you the *.exe, but otherwise you will not see any change to your prompt.

 

Choose a font

We need to choose a font that supports the Nerd Fonts icons, otherwise we end up with a broken prompt. I like the JetBrains Mono font, but you can use any font from the font download page. If you are unsure, you can try many fonts on ProgrammingFonts.org.

 

Download and install the font in Windows

We can download the font directly from Nerd Fonts and the open the *.zip file. I double-clicked the JetBrains Mono Medium Nerd Font Complete Windows Compatible.ttf file to start the font preview tool from Windows:

You can preview the font and install it

If you like what you see, you can click on the Install button to use it inside your applications.

 

Prepare the Windows Terminal

Use the key combination Ctrl + Shift + , to open the settings file. Search for profiles and change the defaults entry to this:

 

Configure the prompt in Windows Terminal

Try to open the configuration file with this command (stop if it does not already exists!):

If it does not exist, stop Notepad and run this command:

Now there should be no error message when you open the configuration in Notepad again:

Copy this line to your $PROFILE file:

You can start a new terminal or run this command to activate your changes in $PROFILE:

This should activate Oh My Posh and gives you a prompt like this one:

The Oh My Posh prompt now works

 

Fix Visual Studio

If we open a Developer Power Shell window, we will see somethings like this:

The Oh My Posh prompt without the correct icons Visual Studio

We need to choose our Nerd Font to fix this issue. Open the Tools / Options settings dialog and go to Environment / Fonts and Colors. Select the Terminal settings and change the font:

Set the correct font in the Terminal Settings for Fonts and Colors

When we save the changed settings, Visual Studio reloads the Power Shell and now it should look as expected:

The Oh My Posh prompt with the correct icons in Visual Studio

 

Fix VS Code

To fix a broken prompt in VS Code, go to File / Settings and search for @feature:terminal font. Set your font there if you only want it to work only in the Terminal:

 Set an explicit font for the terminal

If you want to use your font everywhere, you can change the setting for Editor: Font Family that is linked in the Terminal fonts settings.

This gives you the correct prompt in VS Code:

The Oh My Posh prompt with the correct icons in VS Code

If you see no Oh My Posh prompt at all, you may run the wrong PowerShell version. On my machine I have PowerShell and Windows PowerShell – but only the Windows PowerShell works.

 

Conclusion

There are a few extra steps we need to get Oh My Posh working in all our development environments. But as soon as we went through the hoops it works and gives us the additional information that makes working with Git a lot nicer.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.