PowerShell Customization - Fonts, Prompts, and Autocompletion

3 minutes

Step 1: Install Oh-My-Posh

goto oh-my-posh windows installation page, or just execute the following

1
winget install JanDeDobbeleer.OhMyPosh -s winget

installing oh-my-posh succeeded

Step 2: Choose a Font

Totally optional, but if you want to get a specific font follow this section.

to install a supported font run the following:

1
oh-my-posh font install

I chose cascadia-code.

font installation succeeded

After installation is done click CTRL + SHIFT + , to open the terminal settings

Now add the font.face attribute under the profiles.defaults attribute
(change the font face to the font you downloaded in the previous step.)

1
2
3
4
5
6
7
8
9
10
11
12
{
"profiles":
{
"defaults":
{
"font":
{
"face": "CaskaydiaCove NF"
}
}
}
}

Step 3: Applying oh-my-posh

To apply oh-my-posh shell to our powershell, we will need to adjust our $PROFILE file.

Open your $PROFILE file with

1
notepad $PROFILE

If you get an error that the file doesn’t exist - create it first with

1
New-Item -Path $PROFILE -Type File -Force

Add this line to the $PROFILE file

1
oh-my-posh init pwsh | Invoke-Expression

Save, and then on the terminal run the following command to reload your profile so that the changes take effect

1
. $PROFILE

alt text

Step 4: Customizing the prompt

There are many ways where you can customize the prompt.
You can browse themes here, and look different customizations under Segments section in oh-my-posh docs

I’m going to go with oh-my-posh’s author theme, so what we need to do is change the $PROFILE file again, replacing the line we added there before with the following line

1
oh-my-posh init pwsh --config ~/jandedobbeleer.omp.json | Invoke-Expression

Now lets reload our profile again.

If you are unlucky as I am, you might have gotten the below error too, luckily that’s simple to solve…

alt text

Run the following in powershell administrator mode

1
Install-Module PsReadLine -Force

After that, I closed my open powershell session, and when I opened a new one . $PROFILE works!

Step 5: Icons

If you want to add some icons to the dir list follow the following steps

before:

alt text

open powershell with administrator rights and execute the following

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

then open $PROFILE and add the following line

1
Import-Module -Name Terminal-Icons

Reload your profile with . $PROFILE, and now you have some icons when you execute dir / ls!

alt text

Step 6: Auto-completion (history-based)

Now when styling is out of the way, lets add autocompleteion based on our command history.

open powershell with administator rights and execute

1
Install-Module PSReadLine -Force

now add the following lines to your $PROFILE

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

and you should have autocompletion working!

alt text


Too busy to read tech books?
Join my Telegram channel for bite-sized summaries and curated posts that save you time while keeping you up to date with essential insights!
DISCLAIMER: NO LLM SUMMARIES