My PowerShell prompt configuration

March 19th 2021 PowerShell

I like doing things from the command line and use PowerShell daily. I miss some features in the default Windows PowerShell console and use Windows Terminal and Oh my Posh to improve the experience.

Although the configuration isn't complicated, you only need to do it once. So when you need to do it again (to set up a new computer, for example), you forget the exact steps. Of course, you can follow a guide that you find online, but even that one might not be detailed enough for your needs.

After just completing the configuration on a freshly installed machine, I decided to write down what I did so that I can repeat the process next time.

  • Install Windows Terminal from Microsoft Store.

  • Install Oh my Posh:

    Install-Module oh-my-posh -Scope CurrentUser
    
  • List the available themes and select the one to use:

    Get-PoshThemes
    
  • Open the PowerShell profile file in your favorite text editor:

    code $PROFILE
    
  • Import the module and set the theme in the $PROFILE file and save it:

    Import-Module oh-my-posh
    Set-PoshPrompt -Theme negligible
    
  • Install a Nerd Font of choice to get all the glyphs for Oh my Posh prompt to be rendered correctly. I chose FiraCode, which I also use in code editors. From the downloaded archive, select the TrueType (.ttf) font that you like best (my choice was Fira Code Regular Nerd Font Complete Mono Windows Compatible.ttf) and install it for all users by selecting Install for all users from the file context menu.

  • Press Ctrl+, in Windows Terminal to open the settings file in a text editor. Set the newly installed font as the default one for all profiles by adding a fontFace entry to profile.defaults (you can find the font name in the window that opens when you double click the font .ttf file):

    {
      // ...
      "profiles": {
        "defaults": {
          // Put settings here that you want to apply to all profiles.
          "fontFace": "FiraCode NF"
        }
        //...
      }
      //...
    }
    
  • Restart Windows Terminal to use the new font and PowerShell profile. The configured prompt should greet you with all its glyphs rendered correctly:

My PowerShell prompt

Windows Terminal and Oh my Posh can improve your PowerShell experience. Although the configuration isn't difficult, it took me a while to get everything working as I wanted. In this post, I documented the steps involved so that I can follow them next time.

Get notified when a new blog post is published (usually every Friday):

Copyright
Creative Commons License