Enhancing Windows Terminal with Oh-My-Posh for GitBash, CMD, and PowerShell

Introduction: Having the right tools enhances productivity. A well-designed environment not only improves mood but also boosts coding efficiency significantly.

Demonstration Preview

PowerShell

CMD

Git-Bash

Table of Contents

  1. Understanding Oh-My-Posh
  2. Installing Required Fonts
  3. Configuring Nerd Fonts in Windows Terminal
  4. Setting up Shell Terminals with Oh-My-Posh
  5. Configuring CMD with Oh-My-Posh
  6. Configuring Git Bash with Oh-My-Posh

1. Understanding Oh-My-Posh

Oh My Posh is a customizable prompt engine compatible with any shell, allowing adjustment of prompt strings through functions or variables.

Official website: Home | Oh My Posh

The official site provides comprehensive configuration documentation and theme downloads for interested users.

2. Installing Required Fonts

Nerd Fonts website offers installation of all available fonts.

MesloLGM NF font is recommended, available for download here.

Select all with CTRL+A and install.

3. Configuring Nerd Fonts in Windows Terminal

Settings → Select PowerShell, GitBash, or CMD → Appearance

4. Setting up Shell Terminals with Oh-My-Posh

# Open PowerShell profile file with Notepad
notepad $PROFILE

# If above command fails due to missing profile file, create it
New-Item -Path $PROFILE -Type File -Force

Add the following content to the profile file:

Import-Module posh-git # Import posh-git module
Import-Module oh-my-posh # Import oh-my-posh module

# Initialize theme
oh-my-posh init pwsh --config "C:\Users\YourUsername\AppData\Local\Programs\oh-my-posh\themes\MaterialColorful.omp.json" | Invoke-Expression

# Command completion settings
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

# Encoding fix for Chinese characters
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding

Note: The config path should match your local Oh-My-Posh installation directory. Check system environment variables if uncertain.

Execute the following to apply changes:

. $PROFILE

5. Configuring CMD with Oh-My-Posh

First, install Clink utility by running the executable installer.

Then navigate to Clink installation directory and create an oh-my-posh.lua file containing:

load(io.popen('oh-my-posh init cmd --config C:\\Users\\YourUsername\\AppData\\Local\\Programs\\oh-my-posh\\themes\\agnoster.omp.json'):read("*a"))()

Note: Update the config path to match your local installation directory.

Save the file to complete CMD configuration.

6. Configuring Git Bash with Oh-My-Posh

Copy the theme file from "~\\AppData\\Local\\Programs\\oh-my-posh\\themes\\desired-theme.omp.json" to "C:\\Users\\YourUsername" directory. Add the following command to your ~/.profile file (create with touch .profile if it doesn't exist), then execute . ~/.profile to refresh and restart the terminal.

eval "$(oh-my-posh --init --shell bash --config ~/MaterialColorful.omp.json)"

Reference Documentation

Microsoft Official Guide: Tutorial: Set up a custom prompt for PowerShell or WSL with Oh My Posh

Oh-My-Posh Official Guide: oh-my-posh

Tags: oh-my-posh windows-terminal PowerShell git-bash cmd

Posted on Thu, 04 Jun 2026 17:33:38 +0000 by monezz