- Published on
Setting up oh-my-posh and PSReadLine in PowerShell
Tags:
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
Install-Module oh-my-posh -Scope AllUsersThis 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
Update-Module -Name oh-my-poshTo uninstall
UnInstall-Module -Name oh-my-poshInstall 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.
{
"profiles": {
"defaults": {
"fontFace": "MesloLGM NF"
}
}
}View themes and select one you like
Get-PoshThemesImport 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.
notepad.exe $PROFILEThis will open the PowerShell profile in notepad.
Update the PowerShell with the following
Import-Module oh-my-posh
Set-PoshPrompt powerlevel10k_rainbowThis 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.
Install-PackageProvider -Name NuGet -ForceInstall or update the PowerShellGet
To install
Install-Module -Name PowerShellGet -ForceTo update
Update-Module -Name PowerShellGetInstall PSReadLine
To install
Install-Module -Name PSReadLine -AllowPrereleaseImport and configure PSReadLine
Open the powershell profile
notepad $profileAdd the PSReadLine config
Import-Module PSReadLine
Set-PSReadLineOption -EditMode Windows
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -PredictionViewStyle InlineViewFor more config look here
Install Terminal-Icons
To install the module from the PowerShell Gallery:
Install-Module -Name Terminal-Icons -Repository PSGalleryOpen the powershell profile
notepad $profileImport the terminal font
Import-Module -Name Terminal-IconsOpen a new prompt and verify if you the icons with the following command
Get-ChildItem -Path . -ForceRelated Posts
Continue reading with these related articles
A worktree-aware tmux config with a live status bar
Tmux bindings for git worktree windows (prefix+g, prefix+G), a force-remove kill that handles orphan directories (prefix+X), and a /proc-backed status bar.
Set up Wsl with zsh and oh-my-zsh
In this post we will see how to setup zsh shell in the wsl and use oh-my-zsh.
Set up Windows Terminal with PoshGit, oh-my-posh and Cascadia Code PL
In this post we will see how to setup windows terminal with PoshGit and oh-my-posh to make the terminal more productive