Terminal

This is a fairly simple and straightforward step by step guide to setup Oh My Posh and few other usefull utilities on Powershell.

I'll not deep dive and explain what does what & why install something. You can do a simple google to find out that. Good luck!

If you are on Windows 10, you'll most likely want to do the following steps first,

  • Install Powershell

  • Set Powershell as the Default Profile of Windows Terminal

    • Open Windows Terminal

    • Hit ctrl+,

default-profile-powershell

Rest is same for Win 10 & 11,

  • Install a Nerd Font of your choice

    You can see preview of the fonts at https://www.programmingfonts.org/

  • Set your newly installed font as the default of Windows Terminal

    If you use terminal inside vscode, set value of "terminal.integrated.fontFamily" with your font

  • Install Oh My Posh

    winget install JanDeDobbeleer.OhMyPosh -s winget
  • edit Powershell profile $PROFILE and paste the following

    Replace user-name with your Windows user name & theme-name with your preferred theme in the command Run code $PROFILE to open in VSCode or notepad $PROFILE to open in notepad

oh-my-posh --init --shell pwsh --config C:\Users\user-name\AppData\Local\Programs\oh-my-posh\themes\theme-name.omp.json | Invoke-Expression
Install-Module -Name Terminal-Icons -Repository PSGallery
  • Import Terminal-Icons in $PROFILE

Import-Module -Name Terminal-Icons
Install-Module PSReadLine -AllowPrerelease -Force
  • Import PSReadLine in $PROFILE

Import-Module PSReadLine
  • To get better list view and edit mode, paste the following in $PROFILE

Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows
PSReadLine

You can edit and remove commands from powershell history by modifying $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt

Credits

  • https://0xdf.gitlab.io/2018/11/08/powershell-history-file.html

  • https://www.hanselman.com/blog/my-ultimate-powershell-prompt-with-oh-my-posh-and-the-windows-terminal

Last updated