Skip to content

Instantly share code, notes, and snippets.

@adojos
Last active May 18, 2024 15:11
Show Gist options
  • Save adojos/d7904b76af760430ad086473da759d97 to your computer and use it in GitHub Desktop.
Save adojos/d7904b76af760430ad086473da759d97 to your computer and use it in GitHub Desktop.
Oh-My-Posh Installation on Win PowerShell v5.1 #powershell

Oh-My-Posh Installation on Windows PowerShell v5.1


1. Installation

There are number of ways you can install Oh-My-Posh. But commonly you install Oh-My-Posh either from PSGallery by using PowerShell's 'Install-Module' command or with Oh-My-Posh supplied platform-specific install instructions like 'Winget' on their website. Hence you can choose to run any one of the following.

If you want to use 'winget', run following:

winget install JanDeDobbeleer.OhMyPosh -s winget

If you want to use PSGallery 'Install-Module', run the following:

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

For the PATH to be reloaded, a restart of your terminal is advised


👉 Note: Path to oh-my-posh module directory ($Env:PSModulePath)

The path of the module installation depends upon the '-Scope' used in the module installation command above. The acceptable values for this parameter are 'AllUsers' and 'CurrentUser'.

The AllUsers scope installs modules in a location that's accessible to all users of the computer:

$env:ProgramFiles\WindowsPowerShell\Modules

The CurrentUser installs modules in a location that's accessible only to the current user of the computer. For example:

$HOME\Documents\WindowsPowerShell\Modules

When no Scope is defined, the default is set based on the PowerShellGet version. In PowerShellGet versions 2.0.0 and above, the default is CurrentUser, which doesn't require elevation for install. In PowerShellGet 1.x versions, the default is AllUsers, which requires elevation for install.


👉 Note: Path to PowerShell Home Directory ($PSHOME)

C:\Windows\System32\WindowsPowerShell

2. List Default Available Themes

To display every available theme in the current directory, use the following cmdlet.

Get-PoshThemes

The module installs all themes in the module folder. To find the actual files, you can use the following command:

Get-PoshThemes -list

3. Edit Profile to Replace Existing Prompt

Edit your PowerShell $PROFILE and add the following lines to load Oh-My-Posh module and theme of your choice at startup. Autocompletion is available so it will loop through all available themes. Refer the last section of this gist to know the location of your PowerShell profile.

Import-Module oh-my-posh
Set-PoshPrompt -Theme jandedobbeleer

4. Update Oh-My-Posh Module

In order to update oh-my-posh module to latest available version, run one of the following:

If using 'winget', run the following:

winget upgrade JanDeDobbeleer.OhMyPosh -s winget

If using PSGallery, 'Update-Module', run the following:

Update-Module oh-my-posh

5. Install Dev Fonts (Glyph)

Oh My Posh was designed to use Nerd Fonts. Nerd Fonts are popular fonts that are patched to include icons. We recommend Meslo LGS NF, but any Nerd Font should be compatible with the standard themes.

To see the icons displayed in Oh My Posh, install a Nerd Font, and configure your terminal to use it.


👉 Note: PowerShell Profile Path

AllUsersAllHosts -       C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1

AllUsersCurrentHost -    C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1

CurrentUserAllHosts -    C:\Users\UserName\Documents\WindowsPowerShell\profile.ps1

CurrentUserCurrentHost - C:\Users\UserName\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

👉 Note: PowerShell Modules Path ($ENV: PSModulePath)

CurrentUser -       C:\Users\UserName\Documents\WindowsPowerShell\Modules

AllUsersCurrentHost -    C:\Program Files\WindowsPowerShell\Modules

BuiltInModules (AllUsers) -    C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment