Setting up Windows Terminal for Git

These are the steps to take to set up my terminal the way I like it for Git usage..

GETTING THE THINGS INSTALLED

WINGET – WINDOWS PACKAGE MANAGER

Get or update to the latest App Installer from Microsoft Store. This will include the winget client.

POWERSHELL

Get the .NET Core-powered cross-platform PowerShell from Microsoft Store. Not to be confused with Windows Powershell, which is the older classic one.

WINDOWS TERMINAL

Get Windows Terminal from Microsoft Store.

FONTS

Download and install Caskaydia Cove Nerd fonts from https://github.com/ryanoasis/nerd-fonts/releases/tag/v2.1.0 (later releases doesn’t look right). That is, locate the release assets and download and extract CascadiaCode.zip which contains named fonts. Install by opening Settings in Windows, go to Personalization > Fonts and drag all extracted fonts to the drop area.

OH MY POSH

Install Oh My Posh from Windows Terminal using winget, then restart the terminal to reload PATH:

winget install JanDeDobbeleer.OhMyPosh

PSREADLINE – PREDICTIVE INTELLISENSE

Install PSReadLine as administrator from Powershell by issuing the following:

Install-Module PSReadLine -Force

SETTING THINGS UP

WINDOWS TERMINAL

In Windows Terminal, open settings and apply the following:

  • Startup
    • Make Powershell the default profile
    • Set launch size to 150 x 70, typically
    • Change new instance behavior to Attach to the most recently used window
  • Appearance
    • Change theme to Dark
    • Set tab width mode to Title length
  • Powershell – General
    • Set starting directory to the Git repository base directory
  • Powershell – Appearance
    • Set font face to CaskaydiaCove NF

POWERSHELL

From Windows Terminal, open the profile in Visual Studio Code:

code $Profile.CurrentUserAllHosts

Add the following lines to enable easy reload of the PowerShell profile:

function Reload-Profile {
	@(
		$Profile.AllUsersAllHosts,
		$Profile.AllUsersCurrentHost,
		$Profile.CurrentUserAllHosts,
		$Profile.CurrentUserCurrentHost
	) | ForEach-Object {
		if (Test-Path $_) {
			Write-Output "Running $_"
			. $_
		}
	}
}

Add the following line to enable Oh My Posh:

oh-my-posh --init --shell pwsh --config ~/.theme.omp.json | Invoke-Expression

Add the following lines to enable predictive intellisense with PSReadLine:

if (-Not (Get-Module -ListAvailable -Name PSReadLine)) {
    Import-Module PSReadLine
}

Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle InlineView
Set-PSReadLineOption -EditMode Windows

OH MY POSH

Place the Oh My Posh configuration file at the path specified in the PowerShell profile above. It’s composed to show the pretty Git empowered prompt that I am used to.

This is the final result!