{"slug": "oh-my-posh-for-github-copilot-cli-statusline-catppuccin-theme", "title": "Oh My Posh for GitHub Copilot CLI statusline - Catppuccin theme", "summary": "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.", "body_md": "|\n$ErrorActionPreference = 'Stop' |\n|\n[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new() |\n|\n|\n|\nfunction Format-TokenCount { |\n|\nparam([Nullable[double]]$Value) |\n|\n|\n|\nif ($null -eq $Value) { return '?' } |\n|\nif ($Value -ge 1000000) { return ('{0:0.0}m' -f ($Value / 1000000)) } |\n|\nif ($Value -ge 1000) { return ('{0:0}k' -f ($Value / 1000)) } |\n|\nreturn ([int][Math]::Round($Value)).ToString() |\n|\n} |\n|\n|\n|\n# Copilot sends the statusline payload as JSON on stdin. |\n|\n$payload = [Console]::In.ReadToEnd() |\n|\n|\n|\ntry { |\n|\n$json = $payload | ConvertFrom-Json |\n|\n} catch { |\n|\nWrite-Host -NoNewline 'Copilot status unavailable' |\n|\nexit 0 |\n|\n} |\n|\n|\n|\n$context = $json.context_window |\n|\n|\n|\n$currentTokens = if ($null -ne $context.current_context_tokens) { |\n|\n[double]$context.current_context_tokens |\n|\n} else { |\n|\n$null |\n|\n} |\n|\n|\n|\n$contextLimit = if ($null -ne $context.displayed_context_limit) { |\n|\n[double]$context.displayed_context_limit |\n|\n} else { |\n|\n$null |\n|\n} |\n|\n|\n|\n$cost = $json.cost |\n|\n$linesAdded = if ($null -ne $cost.total_lines_added) { [int]$cost.total_lines_added } else { 0 } |\n|\n$linesRemoved = if ($null -ne $cost.total_lines_removed) { [int]$cost.total_lines_removed } else { 0 } |\n|\n|\n|\n$theme = Join-Path $PSScriptRoot 'statusline.omp.json' |\n|\n$cwd = if ($json.cwd) { [string]$json.cwd } else { (Get-Location).Path } |\n|\n$folderName = Split-Path -Path $cwd -Leaf |\n|\nif ([string]::IsNullOrWhiteSpace($folderName)) { |\n|\n$folderName = $cwd |\n|\n} |\n|\n|\n|\n$branchName = '' |\n|\n# Only show a branch when the payload cwd is actually inside a git work tree. |\n|\n$isRepo = & git -C $cwd rev-parse --is-inside-work-tree 2>$null |\n|\nif ($LASTEXITCODE -eq 0 -and $isRepo -eq 'true') { |\n|\n$branchName = (& git -C $cwd branch --show-current 2>$null).Trim() |\n|\nif ([string]::IsNullOrWhiteSpace($branchName)) { |\n|\n$branchName = (& git -C $cwd rev-parse --short HEAD 2>$null).Trim() |\n|\n} |\n|\n} |\n|\n|\n|\n$env:COPILOT_STATUS_FOLDER = $folderName |\n|\n$env:COPILOT_STATUS_BRANCH = $branchName |\n|\n$env:COPILOT_STATUS_TOKENS = \"$(Format-TokenCount $currentTokens)/$(Format-TokenCount $contextLimit)\" |\n|\n$env:COPILOT_STATUS_CHANGES = if ($linesAdded -or $linesRemoved) { \"+$linesAdded/-$linesRemoved\" } else { '' } |\n|\n|\n|\ntry { |\n|\n# Let Oh My Posh draw the final line; the script only prepares the data. |\n|\n$output = & oh-my-posh print primary --config $theme --pwd $cwd --force --escape=false 2>$null |\n|\nif ([string]::IsNullOrWhiteSpace($output)) { |\n|\nthrow 'Oh My Posh returned no output.' |\n|\n} |\n|\n|\n|\nWrite-Host -NoNewline $output.TrimEnd() |\n|\n} catch { |\n|\n# Fallback stays readable if the theme cannot render for any reason. |\n|\n$branch = if ($env:COPILOT_STATUS_BRANCH) { \" | $($env:COPILOT_STATUS_BRANCH)\" } else { '' } |\n|\n$changes = if ($env:COPILOT_STATUS_CHANGES) { \" | $($env:COPILOT_STATUS_CHANGES)\" } else { '' } |\n|\nWrite-Host -NoNewline \"$($env:COPILOT_STATUS_FOLDER)$branch | $($env:COPILOT_STATUS_TOKENS)$changes\" |\n|\n} |", "url": "https://wpnews.pro/news/oh-my-posh-for-github-copilot-cli-statusline-catppuccin-theme", "canonical_source": "https://gist.github.com/cinnamon-msft/1f52589615967a3118f64c2291532df6", "published_at": "2026-05-13 14:10:03+00:00", "updated_at": "2026-05-30 01:12:48.480753+00:00", "lang": "en", "topics": ["ai-tools"], "entities": ["Oh My Posh", "GitHub Copilot", "Catppuccin"], "alternates": {"html": "https://wpnews.pro/news/oh-my-posh-for-github-copilot-cli-statusline-catppuccin-theme", "markdown": "https://wpnews.pro/news/oh-my-posh-for-github-copilot-cli-statusline-catppuccin-theme.md", "text": "https://wpnews.pro/news/oh-my-posh-for-github-copilot-cli-statusline-catppuccin-theme.txt", "jsonld": "https://wpnews.pro/news/oh-my-posh-for-github-copilot-cli-statusline-catppuccin-theme.jsonld"}}