As a developer, I often work with Container, Kubernetes, Terraform so I love to work with PowerShell with nice UI. I love to setting up a nice terminal, getting the prompt just right, setting my colors, fonts, glyphs, and more. 

Today, I would like to share with you how to create a nice UI using PowerShell

I love my prompt.


Let's get you set up!
First, you need to install PowserShell Core. 

Please visit https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.3

Second, Install Window Terminal

Please visit https://learn.microsoft.com/en-us/windows/terminal/install

Third, Install Oh My Posh, you can also read here https://ohmyposh.dev/docs/installation/windows

Running command: winget install JanDeDobbeleer.OhMyPosh -s winget via PowserShell or Terminal, it's fine.

In order to make kubectl command as alias for short. We need to download kubectl client to local directory

Next, run the command: curl -LO "https://dl.k8s.io/release/v1.19.13/bin/windows/amd64/kubectl.exe" (please be noted that, please select kubectl version you want). For me, I store this in "C:\Users\trphu\Documents\k8s\kubectl.exe".

If you want to setup for other tools like Terraform, Octant, etc. we can do the same and configure them later. 

Next, you need to create a PowerShell folder in C drive. For example "C:\Users\trphu\Documents\PowerShell". Then creating an file "profile.ps1". 

Next, you need to install Terminal Icons which is available herehttps://github.com/devblackops/Terminal-Icons
You can run command: Install-Module -Name Terminal-Icons -Repository PSGallery via Windows Terminal.
After you run the command, it will have an folder inside PowserShell folder


Now, we are going to go back to the PowerShell folder and open profile.ps1 file and edit
In this file, we need to

write some PowerShell script as below:

$pwd = pwd

write-host "Using profile in '$pwd\Documents\PowerShell\profile.ps1':"

Write-Host "Aliases set:"

Write-Host "  k        : kubectl"

set-alias -name k -value 'C:\Users\trphu\Documents\k8s\kubectl.exe'

Write-Host "  t        : terraform"

set-alias -name t -value 'C:\Users\trphu\Documents\terraform\terraform.exe'

Write-Host "  o        : octant"

set-alias -name o -value 'C:\Users\trphu\Documents\octant\octant.exe'

Write-Host "  ki       : k-ice"

set-alias -name ki -value 'C:\Users\trphu\Documents\kice\kubectl-ice.exe'

Write-Host "  ssl      : openssl"

set-alias -name ssl -value 'C:\Program Files\OpenSSL-Win64\bin\openssl.exe'


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

Import-Module oh-my-posh

Import-Module -Name Terminal-Icons

Set-PoshPrompt -Theme 'C:\Users\trphu\Documents\PowerShell\ohmyposhv3-v2.json'


For the fle ohmyposhv3-v2.json, you can download from SCOTT HANSELMAN's github and store the file in PowerShell folder in C drive.
Finnaly, you need to download the fonts, there are a lot of fonts. But I recommend you should use Caskaydia Cove Nerd Font Complete. Then you can install this fonts in C:\Windows\Fonts

Last step, we need to do some configurations
Get Windows Terminal and set a default Shell

Choose the setting from Terminal 
Set start up as PowerShell

From Profile of Setting windows, we select Appearance, change the font to CaskaydiaCove NFM

Save this.

Now, it's time to try your prompt

Reference
https://www.hanselman.com/blog/my-ultimate-powershell-prompt-with-oh-my-posh-and-the-windows-terminal
https://ohmyposh.dev/docs/installation/windows