DEV Community

Nam Phuong Tran
Nam Phuong Tran

Posted on

How to Create a Beautiful PowerShell Prompt with Oh My Posh and Windows Terminal

As a developer working with tools like PowerShell, Kubernetes, Terraform, and others, having a well-customized and visually appealing terminal can significantly enhance your workflow. In this guide, we'll walk through the steps to create a stunning PowerShell prompt using Oh My Posh and Windows Terminal.

Prerequisites
Before we start, make sure you have the following prerequisites in place:

PowerShell Core: If you haven't already installed PowerShell Core, you can find installation instructions here.

Windows Terminal: You can install Windows Terminal by following the guide here.

After installing you can see the default UI as below:

Image description

Oh My Posh: Install Oh My Posh by running the following command in PowerShell or Terminal:

winget install JanDeDobbeleer.OhMyPosh -s winget

Enter fullscreen mode Exit fullscreen mode

Create a PowerShell Folder: Create a folder for PowerShell scripts on your C drive, for example, C:\Users<your-username>\Documents\PowerShell. Inside this folder, create a file named profile.ps1.
Terminal Icons: Install the Terminal Icons module by running the following command in Windows Terminal:

Install-Module -Name Terminal-Icons -Repository PSGallery

Enter fullscreen mode Exit fullscreen mode

Fonts: Download and install the Caskaydia Cove Nerd Font Complete from here. Install this font in C:\Windows\Fonts.
Configuration Steps
Open the profile.ps1 file you created in the PowerShell folder (C:\Users<your-username>\Documents\PowerShell\profile.ps1).

Add the following lines to set up aliases for your tools:

$pwd = pwd
write-host "Using profile in '$pwd\Documents\PowerShell\profile.ps1':"
Import-Module oh-my-posh
Import-Module -Name Terminal-Icons

Set-PoshPrompt -Theme 'C:\Users\<your-username>\Documents\PowerShell\ohmyposhv3-v2.json'

Enter fullscreen mode Exit fullscreen mode

Image description

After that the Terminal UI will look like this

Image description

Download the ohmyposhv3-v2.json theme file from Scott Hanselman's GitHub. Save it in your PowerShell folder (C:\Users<your-username>\Documents\PowerShell).
Open Windows Terminal and go to Settings.

Image description
Set up PowerShell as the default shell for Windows Terminal.
In the Windows Terminal settings, navigate to Profiles > > Appearance and change the font to CaskaydiaCove NFM.

Image description

Image description
Save your settings.
Now, you have a beautifully customized PowerShell prompt with Oh My Posh and Windows Terminal. Enjoy your new, stylish, and efficient development environment!

Image description

Top comments (0)