If you use PowerShell frequently, you know that the default look leaves something to be desired and productivity could improve with a few tweaks.
In this article, you will learn how to customize your PowerShell environment like a pro — from the look to the feel — using tools like Oh My Posh, fonts, and more.
Make your terminal beautiful, functional, and your own.
You need to have PowerShell installed. Many people think that Windows PowerShell (which is already installed by default on Windows) is the same as PowerShell, but they are different! See the comparison table below:
Feature | Windows PowerShell | PowerShell (Core) |
---|---|---|
Executable name | powershell.exe |
pwsh.exe |
Base | .NET Framework | .NET Core / .NET 5+ |
Platform | Windows only | Cross-platform (Windows, Linux, macOS) |
Common versions | 5.1 and earlier | 6.0+ (Core), 7.x (PowerShell) |
Future support | Maintenance only | Actively developed |
To find out if your PowerShell is the default, run these commands below:
$PSVersionTable
Name
is Microsoft.PowerShell.Core
and Version
is 5.1, you are using Windows PowerShell.Version
is 6.0+ or 7.x, you are using PowerShell Core (the modern one).Or:
(Get-Process -Id $PID).Path
powershell.exe
, it is Windows PowerShell.pwsh.exe
, it is PowerShell Core.Here is an example of Windows PowerShell:
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.5607
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.5607
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Process -Id $PID).Path
C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
If your output is similar to this: powershell.exe
then you need to install PowerShell.
You can install it through the Windows Store - PowerShell or just run the command below in Windows PowerShell:
winget install Microsoft.PowerShell
If you are already in Windows Terminal, close it and open it again!
Another cool (and important) thing is to install Windows Terminal, see this article how to install and configure!
After properly installing Windows Terminal and PowerShell, now just set Windows Terminal as Default Shell by choosing PowerShell, to do this do:
Open Windows Terminal;
Click on the down arrow (⌵);
Choose PowerShell in Default Profile as in the image below:
Image in Portuguese
Now let’s go to the next step!
You will need fonts to display the unicodes correctly in the terminal. There are two options:
After installing the fonts, change the font of your Windows Terminal and choose the font: Caskaydia Cove Nerd Font as follows:
Ctrl+,
).Where it says JetBrainsMonoMedium Ner Font, change it to Caskaydia Cove Nerd Font.
Image in Portuguese
Now let’s change the prompt!
Oh My Posh is a prompt customization tool for terminals such as PowerShell, GNU Bash, zsh, among others. It allows you to create a visually attractive and informative prompt, with ready-made themes and icon support via Nerd Fonts.
It is ideal for those who want a functional and aesthetically pleasing terminal.
To install, simply run the command below:
winget install JanDeDobbeleer.OhMyPosh
After that, you need to close and reopen Windows Terminal! If you prefer, you can install it via Windows Store - OhMyPosh.
Now, if you run the command below, you will activate the custom prompt:
oh-my-posh --init --shell pwsh --config ~/jandedobbeleer.omp.json | Invoke-Expression
However, when you close and reopen Windows Terminal, you will notice that it will disappear. So, add it to the $PROFILE
path. If you type this in the terminal, you will notice that it will display the configuration path. However, most likely the subfolders related to the path will not exist.
This is normal. The $PROFILE
points to where the file should be, but it doesn’t automatically create the folder or file.
New-Item -ItemType Directory -Path (Split-Path -Parent $PROFILE) -Force
New-Item -ItemType File -Path $PROFILE -Force
notepad $PROFILE
In that open file, paste the command you used to enable prompt customization:
oh-my-posh --init --shell pwsh --config ~/jandedobbeleer.omp.json | Invoke-Expression
Save the file and after closing and reopening Windows Terminal, note that the configuration will always be displayed!
There are several configurations that you can add, the documentation has a full explanation: https://ohmyposh.dev/docs/.
And to enhance your terminal even more, add an icon module, just run the command: Install-Module -Name Terminal-Icons -Repository PSGallery
and then add another line to the same notepad $PROFILE
file, the one below:
Import-Module -Name Terminal-Icons
Close and open Windows Terminal, run the dir
or ls
commands and note that the files and folders will be listed with colored icons!
Image in Portuguese
Awesome, huh?! For more information, check out this link.
powershell windows shell terminal