Developer Tooling

Engineering a State-Aware Oh My Posh v2 Prompt: Palette Design, Conditional Git Blocks, and Cross-Shell Setup

A walkthrough of building a fast, cross-platform Oh My Posh v2 terminal theme with pixelated powerline transitions, color-coded Git awareness, RAM/timing telemetry, and Python venv indicators.

  • Oh My Posh
  • Bash
  • PowerShell
  • Terminal
  • Developer Experience

Overview

When you switch constantly between Pop!_OS Linux terminals, Windows PowerShell, Angular repositories, Python virtual environments, and .NET projects, your command prompt is the status dashboard you look at hundreds of times a day. A cluttered prompt slows down every command return, while a bare prompt leaves you guessing which Git branch is dirty or whether a virtual environment is active.

My personal Oh My Posh v2 theme (hosted publicly as a GitHub Gist and previewed on the Workshop page) balances glanceable state awareness with fast prompt rendering across shells. Here is how its palette tokens, conditional templates, and two-line ergonomics are structured.

Key Takeaways

  • Centralize every hex color in the top-level Oh My Posh palette block so re-theming or contrast tweaks happen in one place.
  • Use background_templates on the Git segment so repo state (clean, modified, ahead, behind, diverged) reads instantly by color before you even read text.
  • Split telemetry (line 1) from input prompt (line 2) so long directory paths never squeeze your typing space.
  • Pair Nerd Font glyphs with fast execution-time thresholds so short commands stay informative without noisy clutter.

Centralized Palette Tokens and Pixelated Powerline Transitions

Hardcoding raw hex values across a dozen prompt segments makes maintenance tedious. Oh My Posh v2 supports a named palette dictionary referenced via p:token-name syntax throughout every segment. Pairing bright saturated segment backgrounds—Dodger Blue (#3a9aff) for path, Git Green (#2ea043) or Modified Orange (#ff8533) for repository status, Sys Violet (#ca74ff) for RAM and execution time, and Bright Sun (#ffec61) for the 24-hour clock—with pure black foreground ink preserves crisp legibility against dark terminal themes.

Rather than standard sharp powerline triangles, every top-row segment uses the Nerd Font pixelated dither transition (\ue0c6). Combined with Agnoster-style path shortening, even deeply nested workspace paths stay compact while remaining immediately recognizable.

Color token map from the published Oh My Posh v2 gist configuration
Palette TokenHex ColorSegment RoleVisual Trigger
dodger-blue#3a9affWorking directory pathAlways visible on line 1
git-background#2ea043Clean Git branchInside repo with clean tree
git-modified#ff8533Dirty working/staged treeUncommitted working or staged changes
git-ahead / behind#9456ff / #ff4a4aUpstream driftUnpushed commits or behind remote
sys-background#ca74ffRAM % + command durationCombined diamond telemetry block
bright-sun#ffec6124-hour timestampMarks exact time each command returned
mountain-meadow#20d18bPython version & venvActive Python project / virtualenv on line 2

State-Aware Git Templates and Two-Line Ergonomics

The highest-value segment in any developer prompt is Git status. Using Go template conditions inside background_templates, the segment switches automatically between clean green, modified orange, ahead purple, behind red, and diverged bright orange while displaying working counts, staged counts, and stash counts inline.

Moving the session username, active shell name, Python virtual environment diamond, root warning indicator, and OS-colored prompt arrow onto a second line solves the classic wide-prompt annoyance: even when you are four directories deep inside a feature branch, your cursor always starts cleanly near the left margin with full horizontal room for long CLI pipelines.

jsonConditional Git background_templates excerpt from the published Oh My Posh gist
{
  "type": "git",
  "style": "powerline",
  "powerline_symbol": "\ue0c6",
  "foreground": "p:black",
  "background": "p:git-background",
  "background_templates": [
    "{{ if or (.Working.Changed) (.Staging.Changed) }}p:git-modified{{ end }}",
    "{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:git-diverged{{ end }}",
    "{{ if gt .Ahead 0 }}p:git-ahead{{ end }}",
    "{{ if gt .Behind 0 }}p:git-behind{{ end }}"
  ],
  "properties": {
    "fetch_stash_count": true,
    "fetch_status": true,
    "fetch_upstream_icon": true
  }
}

Running the Theme Across Bash, Zsh, and PowerShell

Because Oh My Posh compiles down to a single native binary and reads standard JSON configuration, the exact same gist runs identically on Pop!_OS Linux (Bash), macOS (Zsh), and Windows Terminal (PowerShell). Install any patched Nerd Font (such as JetBrainsMono Nerd Font or CascadiaCode Nerd Font) in your terminal emulator so the pixelated transitions and icons render crisply, then point your shell init hook either directly at the raw GitHub Gist URL or a locally cached JSON file in ~/.config/oh-my-posh/.

bashInitializing the theme in ~/.bashrc (or saving locally for offline speed)
# Cache the gist locally so new terminal tabs open instantaneously offline
mkdir -p ~/.config/oh-my-posh
curl -fsSL https://gist.githubusercontent.com/jlyons789/84706232f38edb6e71ac43da45f5f0d9/raw \
  -o ~/.config/oh-my-posh/minionprion.omp.json

# Add to ~/.bashrc:
eval "$(oh-my-posh init bash --config ~/.config/oh-my-posh/minionprion.omp.json)"

Keeping Prompt Latency Low and Troubleshooting Nerd Font Glyphs

Two practical details separate a daily-driver prompt from a novelty you disable after a week: cold-start latency and glyph rendering across terminals. Pointing oh-my-posh directly at a remote GitHub Gist URL works for quick trials, but caching the JSON locally in ~/.config/oh-my-posh/ avoids any network stall when opening a new shell on Wi-Fi or offline. Running oh-my-posh debug inside a large repository shows per-segment render timing in milliseconds, making it easy to verify that Git status queries stay snappy.

If you ever see empty rectangular tofu boxes instead of the pixelated powerline transitions or branch icons, check your terminal emulator’s font setting rather than the JSON file. Both standalone terminals and embedded IDE terminals (such as Antigravity IDE or VS Code) maintain separate font-family preferences; configuring the same patched Nerd Font in both guarantees identical rendering everywhere.

  • Run `oh-my-posh debug` inside any directory to inspect exact millisecond timings and template outputs for every segment.
  • Set the terminal font family in both your OS terminal emulator and your IDE’s integrated terminal settings to a Nerd Font variant.
  • Keep `fetch_status: true` enabled for everyday repositories, and use Oh My Posh’s built-in segment caching if you work inside massive monorepos.