玩转copilot CLI

一、使用说明

1、CLI 中的 GitHub Copilot 在终端中提供了一个类似聊天的界面,允许您提出有关命令行的问题。您可以要求 GitHub Copilot 提供命令建议或给定命令的解释。

2、CLI 中 GitHub Copilot 唯一支持的语言是英语。

3、CLI 中的 GitHub Copilot 会结合自然语言处理和机器学习来解析您的问题并提供答案。这个过程可以分为多个步骤。

二、输出格式

GitHub Copilot 在 CLI 中生成的响应经过格式化后呈现给您。

CLI 中的 Copilot 使用语法突出显示、缩进和其他格式化功能来提高生成的响应的清晰度。

CLI 中的 Copilot 旨在为您提供与您的问题最相关的答案。然而,它可能并不总能提供您正在寻找的答案。

CLI 中的 GitHub Copilot 用户负责审查和验证系统生成的响应,以确保它们准确且适当。

三、安装程序

3.1 安装GitHub CLI

要在 CLI 中安装 Copilot,您必须安装 GitHub CLI。如果您已安装,则可以跳过该步骤。

### macOS

`gh`可以通过[Homebrew](https://brew.sh/)、[MacPorts](https://www.macports.org/)、[Conda](https://docs.conda.io/en/latest/)、[Spack](https://spack.io/)、[Webi获得,也可以从](https://webinstall.dev/)[发布页面](https://github.com/cli/cli/releases/latest)下载二进制文件。

#### Homebrew

| 安装:            | 升级:            |
| ----------------- | ----------------- |
| brew install gh | brew upgrade gh |

#### MacPorts

| 安装:                 | 升级:                                         |
| ---------------------- | ---------------------------------------------- |
| sudo port install gh | sudo port selfupdate && sudo port upgrade gh|

#### Conda

| 安装:                                   | 升级:                                  |
| ---------------------------------------- | --------------------------------------- |
| conda install gh --channel conda-forge | conda update gh --channel conda-forge|

#### Spack

| 安装:             | 升级:                                   |
| ------------------ | ---------------------------------------- |
| spack install gh | spack uninstall gh && spack install gh |

#### Webi

| 安装:                             | 升级:           |
| ---------------------------------- | ---------------- |
| curl -sS https://webi.sh/gh | sh | webi gh@stable |

### Linux & BSD

`gh`可通过以下方式获得:

- [我们的 Debian 和 RPM 存储库](https://github.com/cli/cli/blob/trunk/docs/install_linux.md);
- 各种 Linux 发行版中社区维护的存储库;
- 与操作系统无关的包管理器,例如[Homebrew](https://github.com/cli/cli#homebrew)、[Conda](https://github.com/cli/cli#conda)、[Spack](https://github.com/cli/cli#spack)、[Webi](https://github.com/cli/cli#webi);
- 我们的[发布页面](https://github.com/cli/cli/releases/latest)作为预编译的二进制文件。

### Windows

`gh`可通过[WinGet](https://github.com/microsoft/winget-cli)、[scoop](https://scoop.sh/)、[Chocolatey](https://chocolatey.org/)、[Conda](https://github.com/cli/cli#conda)、[Webi](https://github.com/cli/cli#webi)以及可下载的 MSI 获得。

#### WinGet

| 安装:                           | 升级:                           |
| -------------------------------- | -------------------------------- |
| winget install --id GitHub.cli| winget upgrade --id GitHub.cli |

**注意**
Windows 安装程序会修改您的 PATH。使用 Windows 终端时,您需要**打开一个新窗口**才能使更改生效。 (仅打开一个新选项卡是*不够*的。)

#### scoop

| 安装:             | 升级:            |
| ------------------ | ----------------- |
| scoop install gh | scoop update gh |

#### Chocolatey

| 安装:             | 升级:             |
| ------------------ | ------------------ |
| choco install gh | choco upgrade gh |

#### Signed MSI

MSI 安装程序可在[发行页面](https://github.com/cli/cli/releases/latest)上下载。

3.2、在 CLI 中安装 Copilot

如果您还没有通过GitHub帐户进行身份验证,请在终端中运行以下命令。

gh auth login

要在 CLI 扩展中安装 Copilot,请运行以下命令。
gh extension install github/gh-copilot

要在CLI中更新Copilot,请运行以下命令。
gh extension install github/gh-copilot

四、开始使用

4.1、解释命令

4.2、获取建议

例如你需要安装git,让copilot给出建议,copilot会告诉你如何安装

你可以这样提问:

gh copilot suggest "Install git"

4.3、执行命令

如果你已经获取到了copilot的建议,现在你需要执行该命令,你可以这样做:

选中Copy command to clipboard,并按enter确认

这时copilot会将命令复制到剪贴板并自动退出交互式会话。 然后,你可以粘贴该命令并自行运行它。

  • 10
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值