跳转到主内容

GitHub Copilot

非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

功能

显示您的 GitHub Copilot 使用统计和配额信息,包括高级交互次数、行内补全和聊天使用量。 该功能灵感来自 Elio Struyf 的 GitHub Copilot Usage Tauri 应用

认证

该功能需通过 GitHub 认证获取 Copilot 用量数据。使用内置的 OAuth 设备码流程:

oh-my-posh auth copilot

流程如下:

  1. 显示设备码和验证 URL

  2. 在浏览器打开 GitHub 授权页面

  3. 提示输入设备码

  4. 安全存储访问令牌供后续使用

令牌将被安全存储并由功能自动调用。

示例配置

{
"type": "copilot",
"style": "diamond",
"leading_diamond": "",
"trailing_diamond": "",
"foreground": "#111111",
"background": "#fee898",
"template": "  {{ .Premium.Percent.Gauge }} ",
"cache": {
"duration": "5m",
"strategy": "session"
},
"options": {
"http_timeout": 1000
}
}

选项

NameTypeDefaultDescription
http_timeoutint20The default timeout for HTTP requests in milliseconds

模板 (信息)

默认模板
 \uec1e {{ .Premium.Percent.Gauge }}

属性

NameTypeDescription
.PremiumCopilotUsagePremium interactions usage data
.Premium.UsedintNumber of premium interactions used
.Premium.LimitintTotal premium interactions available
.Premium.PercentPercentagePercentage of premium quota used (0-100)
.Premium.RemainingPercentagePercentage of premium quota remaining (0-100)
.Premium.UnlimitedboolWhether premium quota is unlimited
.InlineCopilotUsageInline completions usage data
.Inline.UsedintNumber of inline completions used
.Inline.LimitintTotal inline completions available
.Inline.PercentPercentagePercentage of inline quota used (0-100)
.Inline.RemainingPercentagePercentage of inline quota remaining (0-100)
.Inline.UnlimitedboolWhether inline quota is unlimited
.ChatCopilotUsageChat usage data
.Chat.UsedintNumber of chat interactions used
.Chat.LimitintTotal chat interactions available
.Chat.PercentPercentagePercentage of chat quota used (0-100)
.Chat.RemainingPercentagePercentage of chat quota remaining (0-100)
.Chat.UnlimitedboolWhether chat quota is unlimited
.BillingCycleEndstringEnd date of current billing cycle

百分比方法

Percentage 类型除了数值外还提供额外功能:

MethodReturnsDescription
.Gauge()stringVisual gauge showing remaining capacity using 5 bar blocks (▰▰▰▰▱)
.GaugeUsed()stringVisual gauge showing used capacity using 5 bar blocks (▰▱▱▱▱)
.String()stringNumeric percentage value (e.g., "75" for use in templates)

示例用量可视化(显示剩余容量):

  • 已用 0%(剩余 100%):▰▰▰▰▰

  • 已用 20%(剩余 80%):▰▰▰▰▱

  • 已用 40%(剩余 60%):▰▰▰▱▱

  • 已用 60%(剩余 40%):▰▰▱▱▱

  • 已用 80%(剩余 20%):▰▱▱▱▱

  • 已用 100%(剩余 0%):▱▱▱▱▱

示例 gaugeUsed 可视化(显示已用容量):

  • 已用 0%:▱▱▱▱▱

  • 已用 20%:▰▱▱▱▱

  • 已用 40%:▰▰▱▱▱

  • 已用 60%:▰▰▰▱▱

  • 已用 80%:▰▰▰▰▱

  • 已用 100%:▰▰▰▰▰

使用量表的模板示例:

"template": "{{ .Premium.Percent.Gauge() }} {{ .Premium.Used }}/{{ .Premium.Limit }}"

显示已用容量的模板示例:

"template": "{{ .Premium.Percent.GaugeUsed() }} {{ .Premium.Used }}/{{ .Premium.Limit }}"