Appearance
如果你在 Windows 上用 Windows Terminal Canary 版本,可以直接在终端里打开 Copilot Chat 窗口提问——输入自然语言描述你想做什么,Copilot 给出命令,点击即可插入到命令行。适合记不住命令参数或需要快速组合命令的场景。
GitHub Copilot in Windows Terminal:在终端里直接问 AI
功能概述
GitHub Copilot 与 Windows Terminal 的集成,让你在不离开终端窗口的情况下,直接向 AI 提问命令行相关问题——"怎么用 git 找出上周所有提交"、"如何批量重命名文件夹"——然后点击答案直接插入到命令行执行。
前置条件
使用此功能需要:
- Windows Terminal Canary 版本(稳定版暂不支持此功能)
- GitHub Copilot 订阅(免费版或付费版均可)
- 在 Windows Terminal 中完成 Copilot 账号连接
Windows Terminal Canary 是微软 Terminal 的预览版,包含最新功能。与 PowerShell 7 或 Windows PowerShell 均兼容。
基本使用
- 在 Windows Terminal 中打开 Terminal Chat 窗口
- 在输入框中用自然语言描述你的问题:
- "查看最后 50 行日志并过滤 ERROR"
- "用 PowerShell 统计某个目录下的文件数量"
- "Git 如何撤销上一次 commit 但保留改动"
- 按 Enter 发送
- Copilot 的回答显示在问题下方
- 点击答案中的命令,它会自动插入到命令行中,你可以进一步编辑后执行
适用场景
| 场景 | 示例 |
|---|---|
| 忘记命令参数 | "rsync 如何排除某个目录" |
| 组合复杂命令 | "用 find 找到所有 .log 文件并删除超过 7 天的" |
| PowerShell 语法 | "PowerShell 怎么格式化 JSON 输出" |
| 排查错误 | "出现 'permission denied' 时如何快速定位" |
与 Copilot CLI 的关系
Copilot CLI(gh copilot)是另一种在命令行使用 Copilot 的方式,两者不冲突:
| Copilot in Windows Terminal | Copilot CLI | |
|---|---|---|
| 平台 | 仅 Windows Terminal Canary | 跨平台(Windows/Mac/Linux) |
| 集成方式 | Terminal UI 内置 Chat 面板 | gh copilot suggest 命令 |
| 交互体验 | 对话式,答案点击插入 | 命令式,逐步确认 |
| Shell 支持 | 全部(PowerShell/cmd/bash) | 全部 |
如果你在 Mac/Linux 工作,或者喜欢命令行风格,推荐使用 Copilot CLI;如果你主要在 Windows 上,Terminal 集成提供更流畅的 UI 体验。
企业策略限制
如果你的账号归属于某个 GitHub 组织,且该组织禁用了 Copilot CLI,那么 Copilot in Windows Terminal 的功能也会受限——因为底层共享同一套权限控制。请联系组织管理员确认策略配置。
常见问题
Q: Windows Terminal 稳定版为什么没有这个功能?
A: Terminal Chat 功能目前仍在 Canary(预览)阶段,微软会在功能稳定后推入正式版。可以从 Microsoft Store 单独安装 Windows Terminal Canary,与稳定版并存。
Q: 除了 Copilot,Terminal Canary 还集成了哪些 AI 工具?
A: Terminal Canary 还在探索其他 AI 功能,但目前主要的 AI 集成是 GitHub Copilot。微软也有自己的 Bing/Azure OpenAI 集成在其他工具中,但 Terminal 内当前主要是 GitHub Copilot。
Q: 这个功能需要额外收费吗?
A: 不需要额外订阅,GitHub Copilot 现有订阅即可使用(包括免费版)。但如果询问消耗 Premium Requests,会按正常 AI Credits 扣费。