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!
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".
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.
0 Comments
Post a Comment