GitHub Copilot
非官方测试版翻译
本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →
功能
显示您的 GitHub Copilot 使用统计和配额信息,包括高级交互次数、行内补全和聊天使用量。 该功能灵感来自 Elio Struyf 的 GitHub Copilot Usage Tauri 应用。
认证
该功能需通过 GitHub 认证获取 Copilot 用量数据。使用内置的 OAuth 设备码流程:
oh-my-posh auth copilot
流程如下:
-
显示设备码和验证 URL
-
在浏览器打开 GitHub 授权页面
-
提示输入设备码
-
安全存储访问令牌供后续使用
令牌将被安全存储并由功能自动调用。
示例配置
- json
- yaml
- toml
{
"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
}
}
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
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
选项
| Name | Type | Default | Description |
|---|---|---|---|
http_timeout | int | 20 | The default timeout for HTTP requests in milliseconds |
模板 (信息)
默认模板
\uec1e {{ .Premium.Percent.Gauge }}
属性
| Name | Type | Description |
|---|---|---|
.Premium | CopilotUsage | Premium interactions usage data |
.Premium.Used | int | Number of premium interactions used |
.Premium.Limit | int | Total premium interactions available |
.Premium.Percent | Percentage | Percentage of premium quota used (0-100) |
.Premium.Remaining | Percentage | Percentage of premium quota remaining (0-100) |
.Premium.Unlimited | bool | Whether premium quota is unlimited |
.Inline | CopilotUsage | Inline completions usage data |
.Inline.Used | int | Number of inline completions used |
.Inline.Limit | int | Total inline completions available |
.Inline.Percent | Percentage | Percentage of inline quota used (0-100) |
.Inline.Remaining | Percentage | Percentage of inline quota remaining (0-100) |
.Inline.Unlimited | bool | Whether inline quota is unlimited |
.Chat | CopilotUsage | Chat usage data |
.Chat.Used | int | Number of chat interactions used |
.Chat.Limit | int | Total chat interactions available |
.Chat.Percent | Percentage | Percentage of chat quota used (0-100) |
.Chat.Remaining | Percentage | Percentage of chat quota remaining (0-100) |
.Chat.Unlimited | bool | Whether chat quota is unlimited |
.BillingCycleEnd | string | End date of current billing cycle |
百分比方法
Percentage 类型除了数值外还提供额外功能:
| Method | Returns | Description |
|---|---|---|
.Gauge() | string | Visual gauge showing remaining capacity using 5 bar blocks (▰▰▰▰▱) |
.GaugeUsed() | string | Visual gauge showing used capacity using 5 bar blocks (▰▱▱▱▱) |
.String() | string | Numeric 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 }}"