Anto Subash.

Published on

Setting up oh-my-posh and PSReadLine in PowerShell

Table of contents

Oh My Posh

Oh my is a prompt theme engine for PowerShell. It has many builtin themes and you can also create your own theme if you want. Lets see how you can install it and setup ohmyposh.

Install in PowerShell Module

1Install-Module oh-my-posh -Scope AllUsers

This will install ohmyposh to all the users.

If you are using the older version of the Oh My Posh. please update or uninstall the module.

To update

1Update-Module -Name oh-my-posh

To uninstall

1UnInstall-Module -Name oh-my-posh

Install fonts

Oh My Posh uses Nerd Font. It is recommed to use Meslo Lgm NF

Download the fonts and install install it.

Setting the font in Windows Terminal

Once the font is installed set the font as a default font in Windows Terminal.

1{
2  "profiles": {
3    "defaults": {
4      "fontFace": "MesloLGM NF"
5    }
6  }
7}

View themes and select one you like

1Get-PoshThemes

Import module and set theme

Once you have decided on the theme we can import module and set the theme.

We need to update the PowerShell profile to import and set the theme.

To open the profile use this command.

1notepad.exe $PROFILE

This will open the PowerShell profile in notepad.

Update the PowerShell with the following

1Import-Module oh-my-posh
2Set-PoshPrompt powerlevel10k_rainbow

This will import the Oh My Posh and set the theme.

Install PSReadLine and PowerShellGet

Before updating PowerShellGet, you should always install the latest NuGet provider. From an elevated PowerShell session, run the following command.

1Install-PackageProvider -Name NuGet -Force

Install or update the PowerShellGet

To install

1Install-Module -Name PowerShellGet -Force

To update

1Update-Module -Name PowerShellGet

Install PSReadLine

To install

1Install-Module -Name PSReadLine -AllowPrerelease

Import and configure PSReadLine

Open the powershell profile

1notepad $profile

Add the PSReadLine config

1Import-Module PSReadLine
2Set-PSReadLineOption -EditMode Windows
3Set-PSReadLineOption -PredictionSource History
4Set-PSReadLineOption -PredictionViewStyle ListView
5Set-PSReadLineOption -PredictionViewStyle InlineView

For more config look here

Install Terminal-Icons

To install the module from the PowerShell Gallery:

1Install-Module -Name Terminal-Icons -Repository PSGallery

Open the powershell profile

1notepad $profile

Import the terminal font

1Import-Module -Name Terminal-Icons

Open a new prompt and verify if you the icons with the following command

1Get-ChildItem -Path . -Force