Windows Terminal Setup with State Information

Windows Terminal is a modern console terminal supporting multiple interpreters (shells) and tabs. With integrated status information (path, git branch, elevation, etc), it provides real value over running Command Prompt (cmd.exe) or Powershell (pwsh.exe) directly.

Command Shells, Fish and Powershell with Oh My Posh

Linux always had various alternative shells you could use. But bash is pretty much the baseline or standard. Bash is extensible. But alternative shells can provide additional useful functionality, or do so by default over having to set them up.

If I do not use minimal, baseline bash, then I use Fish Shell, which provides good additions and defaults.

One fish feature - related to this post - is that the status information user@hostname and current path is replaced by user@hostname, the abbreviated path, and git information (current branch). The abbreviation is quite useful when working with long and deep paths.

Fish shell prompt with context

On Windows, Command Prompt (cmd.exe) and Batch scripting (.bat files) is the old commandline tech stack. The new commandline tech stack is Powershell (pwsh.exe). Powershell (pwsh.exe), based on multi-platform .NET, supersedes Windows Powershell (powershell.exe), which only runs on Windows.

For a while now, Microsoft put effort into developing Windows Terminal; a modern host application for the command-line shells like Command Prompt and Powershell. It also supports Windows Subsystem for Linux (WSL), so you can use the subsystems Linux shells too. Multiple profiles can be configured, for different settings, or elevated admin execution (administrative console), or connecting to remote servers via ssh with distinctive icons.

By default, Powershell shows a PS C:\path> prefix on the command line. By setting up Oh My Posh, a status/context line is printed before the command prompt line which always starts on the left.

Screenshot of pwsh with Oh My Posh context line and prompt

Setting up Powershell Context with Oh My Posh

These are the straight forward, opinionated steps to set it up.

  1. Install Windows Terminal (MS Store) Open in Store App
  2. Install Oh-My-Posh (MS Store) Open in Store App
  3. (Re)Launch Powershell Terminal (not Windows Powershell)
  4. Install CaskaydiaCove NF font with oh-my-posh font install CascadiaCode
  5. (Re)Launch Powershell Terminal (not Windows Powershell)
  6. Set font via Settings → Profiles → Defaults → Appearance → Font face ⇒ CaskaydiaCove NF
  7. Edit startup script with notepad $PROFILE
  8. Add line oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\paradox.omp.json" | Invoke-Expression

Alternative Fonts

Nerd Font is a project extending existing fonts with additional glyphs (characters and symbols). These are particularly useful for information and status information via text within the terminal. The oh-my-posh font install command provides an interface for downloading any Nerd Font.

CaskaydiaCove NF of CascadiaCode is a patched font of the Windows Terminal/Microsoft IDE default font Cascadia Code.

Oh-My-Posh itself recommends Meslo LGM NF of the Meslo fonts.

  1. Install font with oh-my-posh font install Meslo
  2. (Re)Launch Powershell Terminal (not Windows Powershell)
  3. Set font via Settings → Profiles → Defaults → Appearance → Font face ⇒ CaskaydiaCove NF

Resources: ms docs - install nerd font, Oh My Posh fonts docs, Nerd Font website, latest Nerd Font release

Alternative Themes

Oh My Posh themes provide alternative coloring and context information, formatting, and style.

  1. Edit startup script with notepad $PROFILE
  2. Instead of paradox use one of the alternative Themes in init call oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\paradox.omp.json" | Invoke-Expression

Minimal Themes

Oh-My-Posh labels themes minimal when they do not require patched fonts (for their additional/niche symbols). See their themes listing for such alternatives.

Powershell File Listing File Icons

The Powershell module Terminal Icons adds file type icons to file listings (like on dir, Get-ChildItem, or Get-Item). It relies on patched Nerd Fonts for the icon glyphs.

  1. Install-Module -Name Terminal-Icons -Repository PSGallery
  2. Edit startup script with notepad $PROFILE
  3. Add line Import-Module -Name Terminal-Icons

Upcoming Windows Terminal Features

As side notes, the next Windows Terminal version 1.15 will bring will

  • Introduce keyboard mark mode, allowing selecting text from the text buffer
  • Scroll marks to scroll-jump to significant lines/sections