cd /news/ai-tools/oh-my-posh-for-github-copilot-cli-st… · home topics ai-tools article
[ARTICLE · art-18251] src=gist.github.com pub= topic=ai-tools verified=true sentiment=· neutral

Oh My Posh for GitHub Copilot CLI statusline - Catppuccin theme

A developer created a PowerShell script that integrates GitHub Copilot's CLI statusline with Oh My Posh, using a Catppuccin theme. The script parses JSON payloads from Copilot to display real-time token usage, context window limits, and line changes, then passes the data to Oh My Posh for rendering. It includes fallback logic to show a plain text status if the theme fails to load.

read2 min publishedMay 13, 2026

| $ErrorActionPreference = 'Stop' | | [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new() | | | | function Format-TokenCount { | | param([Nullable[double]]$Value) | | | | if ($null -eq $Value) { return '?' } | | if ($Value -ge 1000000) { return ('{0:0.0}m' -f ($Value / 1000000)) } | | if ($Value -ge 1000) { return ('{0:0}k' -f ($Value / 1000)) } | | return ([int][Math]::Round($Value)).ToString() | | } | | | | | $payload = [Console]::In.ReadToEnd() | | | | try { | | $json = $payload | ConvertFrom-Json | | } catch { | | Write-Host -NoNewline 'Copilot status unavailable' | | exit 0 | | } | | | | $context = $json.context_window | | | | $currentTokens = if ($null -ne $context.current_context_tokens) { | | [double]$context.current_context_tokens | | } else { | | $null | | } | | | | $contextLimit = if ($null -ne $context.displayed_context_limit) { | | [double]$context.displayed_context_limit | | } else { | | $null | | } | | | | $cost = $json.cost | | $linesAdded = if ($null -ne $cost.total_lines_added) { [int]$cost.total_lines_added } else { 0 } | | $linesRemoved = if ($null -ne $cost.total_lines_removed) { [int]$cost.total_lines_removed } else { 0 } | | | | $theme = Join-Path $PSScriptRoot 'statusline.omp.json' | | $cwd = if ($json.cwd) { [string]$json.cwd } else { (Get-Location).Path } | | $folderName = Split-Path -Path $cwd -Leaf | | if ([string]::IsNullOrWhiteSpace($folderName)) { | | $folderName = $cwd | | } | | | | $branchName = '' | | | $isRepo = & git -C $cwd rev-parse --is-inside-work-tree 2>$null | | if ($LASTEXITCODE -eq 0 -and $isRepo -eq 'true') { | | $branchName = (& git -C $cwd branch --show-current 2>$null).Trim() | | if ([string]::IsNullOrWhiteSpace($branchName)) { | | $branchName = (& git -C $cwd rev-parse --short HEAD 2>$null).Trim() | | } | | } | | | | $env:COPILOT_STATUS_FOLDER = $folderName | | $env:COPILOT_STATUS_BRANCH = $branchName | | $env:COPILOT_STATUS_TOKENS = "$(Format-TokenCount $currentTokens)/$(Format-TokenCount $contextLimit)" | | $env:COPILOT_STATUS_CHANGES = if ($linesAdded -or $linesRemoved) { "+$linesAdded/-$linesRemoved" } else { '' } | | | | try { | | | $output = & oh-my-posh print primary --config $theme --pwd $cwd --force --escape=false 2>$null | | if ([string]::IsNullOrWhiteSpace($output)) { | | throw 'Oh My Posh returned no output.' | | } | | | | Write-Host -NoNewline $output.TrimEnd() | | } catch { | | | $branch = if ($env:COPILOT_STATUS_BRANCH) { " | $($env:COPILOT_STATUS_BRANCH)" } else { '' } | | $changes = if ($env:COPILOT_STATUS_CHANGES) { " | $($env:COPILOT_STATUS_CHANGES)" } else { '' } | | Write-Host -NoNewline "$($env:COPILOT_STATUS_FOLDER)$branch | $($env:COPILOT_STATUS_TOKENS)$changes" | | } |

── more in #ai-tools 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/oh-my-posh-for-githu…] indexed:0 read:2min 2026-05-13 ·