Aller au contenu principal

GitHub Copilot CLI

Traduction Bêta Non Officielle

Cette page a été traduite par PageTurner AI (bêta). Non approuvée officiellement par le projet. Vous avez trouvé une erreur ? Signaler un problème →

Description

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.

Exemple de configuration

{
"type": "copilot_cli",
"style": "diamond",
"leading_diamond": "",
"trailing_diamond": "",
"foreground": "#111111",
"background": "#fee898",
"template": "  {{ .Model.DisplayName }}  {{ .TokenGauge }} "
}

Modèle (info)

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

Paramètres

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

Propriétés

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")

Propriétés du modèle

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

Propriétés de l'espace de travail

NameTypeDescription
.CurrentDirstringCurrent working directory

Remote Properties

NameTypeDescription
.ConnectedboolWhether a remote connection is active

Propriétés des coûts

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

Propriétés de ContextWindow

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

Méthodes de pourcentage

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")
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.

Fonctionnement

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.