Back to Oh My Posh

GitHub Copilot CLI

website/docs/segments/cli/copilot-cli.mdx

29.14.08.5 KB
Original Source

What

Display GitHub Copilot CLI session information including the current AI model, token usage, and workspace details. Shows a visual gauge of context window usage and formatted token/duration information for monitoring your Copilot CLI session.

This segment integrates with GitHub Copilot CLI's statusline functionality to provide real-time session data in your prompt.

For setup instructions, see Change your prompt.

Sample Configuration

import Config from "@site/src/components/Config.js";

<Config data={{ type: "copilot_cli", style: "diamond", leading_diamond: "\ue0b6", trailing_diamond: "\ue0b4", foreground: "#111111", background: "#fee898", template: " \uec1e {{ .Model.DisplayName }} \uf2d0 {{ .TokenGauge }} ", }} />

Template (info)

:::note default template

template
 \uec1e {{ .Model.DisplayName }} \uf2d0 {{ .TokenGauge }}

:::

Options

NameTypeDefaultDescription
gauge_marked_charstringCharacter used for filled blocks in gauge visualizations
gauge_unmarked_charstringCharacter used for empty blocks in gauge visualizations

Properties

NameTypeDescription
.CWDstringCurrent working directory
.SessionIDstringUnique identifier for the Copilot CLI session
.SessionNamestringCustom session name; empty when absent
.TranscriptPathstringPath to the session transcript directory
.ModelModelAI model information
.WorkspaceWorkspaceWorkspace directory information
.RemoteRemoteRemote connection state
.VersionstringCopilot CLI version
.UsernamestringAuthenticated username; empty when absent
.CostCostDuration and line-change information
.ContextWindowContextWindowToken usage information
.TokenUsagePercentPercentagePercentage of context window used (0-100)
.TokenGaugestringGauge showing remaining context capacity using configured characters (e.g., ▰▰▰▱▱)
.TokenGaugeUsedstringGauge showing used context capacity using configured characters (e.g., ▰▰▱▱▱)
.RemainingPercentPercentagePercentage of context window remaining (0-100)
.RemainingTokensCountintNumber of remaining context window tokens; 0 when context window size is unknown
.FormattedTokensstringHuman-readable token count (e.g., "1.2K", "15.3M")
.FormattedDurationstringTotal session duration (e.g., "2m 5s")
.FormattedAPIDurationstringAPI wait time (e.g., "0m 45s")

Model Properties

NameTypeDescription
.IDstringTechnical model identifier
.DisplayNamestringHuman-readable model name (e.g., "claude-sonnet-4.6 (medium)")

Workspace Properties

NameTypeDescription
.CurrentDirstringCurrent working directory

Remote Properties

NameTypeDescription
.ConnectedboolWhether a remote connection is active

Cost Properties

NameTypeDescription
.TotalDurationMSDurationMSTotal session duration in milliseconds (formats as "Xm Ys")
.TotalAPIDurationMSDurationMSTime spent waiting for API responses (formats as "Xm Ys")
.TotalLinesAddedintLines of code added in the session
.TotalLinesRemovedintLines of code removed in the session
.TotalPremiumRequestsintNumber of premium model requests made in the session

ContextWindow Properties

NameTypeDescription
.ContextWindowSize*intMaximum context window size; nil when unknown
.UsedPercentage*float64Percentage used (0-100); nil when unknown
.RemainingPercentage*float64Percentage remaining (0-100); nil when unknown
.RemainingTokens*intRemaining token count; nil when unknown
.CurrentContextTokensintTokens in the current active context
.TotalInputTokensintTotal input tokens used in the session
.TotalOutputTokensintTotal output tokens generated in the session
.TotalCacheReadTokensintTotal tokens read from cache
.TotalCacheWriteTokensintTotal tokens written to cache
.TotalReasoningTokensintTotal reasoning tokens used in the session
.TotalTokensintGrand total of all tokens used in the session
.LastCallInputTokensintInput tokens for the most recent API call
.LastCallOutputTokensintOutput tokens for the most recent API call

Percentage Methods

The Percentage type (returned by .TokenUsagePercent, .RemainingPercent) provides additional methods for direct use in templates:

MethodReturnsDescription
.GaugestringVisual gauge showing remaining capacity using hardcoded / characters
.GaugeUsedstringVisual gauge showing used capacity using hardcoded / characters
.StringstringNumeric percentage value (e.g., "75")

:::tip Custom gauge characters Use .TokenGauge and .TokenGaugeUsed instead of the raw .Percentage methods above — they respect the gauge_marked_char and gauge_unmarked_char options. :::

How it works

The oh-my-posh copilot command reads GitHub Copilot CLI's session JSON from stdin, caches the parsed data, then renders your configured prompt. Copilot CLI sends a fresh JSON payload on every statusline refresh.

The segment is only visible when Copilot CLI is actively providing session data.