Oh My Posh Profile Mk2

Creating a custom Windows Terminal and VS Code Profile with Oh My Posh

What is Oh My Posh?

Alt text

Oh-My-Posh is a framework for enhancing the command prompt in various terminal environments, primarily designed for PowerShell on Windows. It provides a customizable and visually appealing prompt with additional information, such as Git branch status, virtual environment indicators, and more.

Here are some key features of Oh-My-Posh:

Customization: Users can customize the prompt appearance according to their preferences. Oh-My-Posh supports theming, so users can choose from existing themes or create their own.

  • Git Integration:
    Oh-My-Posh often includes Git integration, displaying information about the current Git branch, changes, and other Git-related details directly in the prompt.

  • PowerShell Core Support:
    Oh-My-Posh is compatible with both Windows PowerShell and PowerShell Core, making it versatile across different PowerShell environments.

  • Cross-Platform Compatibility:
    While initially developed for Windows, Oh-My-Posh is designed to work cross-platform. It can be used with various terminal emulators on different operating systems.

  • Segmented Prompt:
    The prompt is often divided into segments, each displaying different information, providing a more organized and informative command line interface.

How does Oh-My-Posh help me?

Since working for a CSP “Cloud Service Provider” Oh My Posh has become a staple in my daily workflow. It’s a fantastic tool that allows you to customise your PowerShell prompt with a variety of themes and icons. You can find out more about Oh My Posh here. It also gives you the ability to know which customer environment you are connected to, which is a massive bonus when you are working with multiple customers and lots of context switching during the day! Thus I started looking at creating a Powershell wrapped script which would look to insatll and configure Oh-My-Posh for me and ensure that I get the same user experience across all my devices and terminals, that being Windows Terminal and Visual Studio Code.

Thus the Mark One Edition was created, If you’re feeling nostalgic you can find the archived repository branch here Oh-My-Posh-Mk1

However, Since creating that branch, I’ve learnt more and found more tools and modules that I wanted to include in my profile. Thus I decided to create a new branch and start from scratch. This time making the script more automated and more modular. Thus the Mark Two Edition was born! From the overview readme of the repository, you can see the following: Oh-My-Posh-Mk2

Configure Oh My Posh Profile - Windows Edition

NEW DEVICE SETUP
Please open Powershell 5.1 as Administrator and run the following commands

Check PowerShell Execution Policy - If Execution Policy is Default update to RemoteSigned

1
Get-ExecutionPolicy

Update Execution Policy

1
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned 

Accept the Execution Policy Change: [A] Yes to all

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"):

Download PsProfile Script

1
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/smoonlee/oh-my-posh-profile/main/New-PsProfile.ps1" -OutFile "$PWD\New-PsProfile.ps1" 

Execute Script

1
.\New-PsProfile.ps1

Configure Oh My Posh Profile - Linux Edition

1
curl -s https://raw.githubusercontent.com/smoonlee/oh-my-posh-profile/main/New-BashProfile.sh -o $HOME/New-BashProfile.sh

Execute Script

1
bash New-BashProfile.sh

Post Configuration

WSL - Kubernetes Context Config

You might need to create the .kube folder first

mkdir $HOME/.kube

Then create a symbolic link to the Windows .kube folder

NOTE: Please update the Users folder to match your Windows User folder

ln -sf /mnt/c/Users/<username>/.kube/config $HOME/.kube/config

Windows Terminal Profile Preview

Alt text

Share with your network!

Built with Hugo - Theme Stack designed by Jimmy