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.
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.
Setting up Powershell Context with Oh My Posh
These are the straight forward, opinionated steps to set it up.
- Install Windows Terminal (MS Store) Open in Store App
- Install Oh-My-Posh (MS Store) Open in Store App
- (Re)Launch Powershell Terminal (not Windows Powershell)
- Install CaskaydiaCove NF font with
oh-my-posh font install CascadiaCode
- (Re)Launch Powershell Terminal (not Windows Powershell)
- Set font via Settings → Profiles → Defaults → Appearance → Font face ⇒ CaskaydiaCove NF
- Edit startup script with
notepad $PROFILE
- 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.
- Install font with
oh-my-posh font install Meslo
- (Re)Launch Powershell Terminal (not Windows Powershell)
- 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.
- Edit startup script with
notepad $PROFILE
- Instead of
paradox
use one of the alternative Themes in init calloh-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.
Install-Module -Name Terminal-Icons -Repository PSGallery
- Edit startup script with
notepad $PROFILE
- 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