Use Oh My Posh to make Terminal more useful

Oh My Posh is a tool designed to enhance the user experience and productivity of individuals working with command-line interfaces by allowing them to customize their shell prompts.

Written for Windows 11

Setup Windows Terminal

https://github.com/microsoft/terminal

Install Oh My Posh

winget install JanDeDobbeleer.OhMyPosh -s winget

Update Oh My Posh

Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))

Install a font

oh-my-posh font install

Choose your font, I like Meslo.

Once install configure Terminal to use it by editing the settings.json file. An easy way to open this file is to hit ctrl - shft - , when Terminal is in focus.

Under the defaults block set the font.

{
    "profiles":
    {
        "defaults":
        {
            "font":
            {
                "face": "MesloLGM Nerd Font"
            }
        }
    }
}

Configure Powershell to use Oh My Posh

Open the Powershell profile text file.

notepad $PROFILE

Add the following line

oh-my-posh init pwsh | Invoke-Expression

Reload your Powershell session to trigger the change

. $PROFILE

Install Themes

To install the current themes

Get-PoshThemes

Themes location: C:\Users\userName\AppData\Local\Programs\oh-my-posh\themes

To change your theme, adjust the init script in C:\Users\neilg_fe5udmm\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1.

Example:

oh-my-posh init pwsh --config 'C:\Users\userName\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json' | Invoke-Expression

Predictive Intellisense

Install the library.

Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck

Add this to $PROFILE

# Add auto complete (requires PSReadline 2.2.0-beta1+ prerelease)
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows

Additional icons

Install the library.

Install-Module -Name Terminal-Icons -Repository PSGallery

Add this to $PROFILE

# Additional icons
Import-Module -Name Terminal-Icons

My favoured theme

References

Oh My Posh

Microsoft Terminal

Last modified July 21, 2024: update (e2ae86c)