Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to main content

在 CLI 中配置 GitHub Copilot

了解如何为 配置设置和设置别名。

设置别名

可以为 创建别名以减少击键次数,并允许 代表你执行命令。

要允许 执行命令,必须运行以下命令以创建别名(而不是像对另一个 shell 命令那样创建别名)。

执行以下命令以创建别名之后,可以运行 ghcsghce 而不是 gh copilot suggestgh copilot explain

Bash

Shell
echo 'eval "$(gh copilot alias -- bash)"' >> ~/.bashrc

PowerShell

Shell
$GH_COPILOT_PROFILE = Join-Path -Path $(Split-Path -Path $PROFILE -Parent) -ChildPath "gh-copilot.ps1"
gh copilot alias -- pwsh | Out-File ( New-Item -Path $GH_COPILOT_PROFILE -Force )
echo ". `"$GH_COPILOT_PROFILE`"" >> $PROFILE

Zsh

Shell
echo 'eval "$(gh copilot alias -- zsh)"' >> ~/.zshrc

更改默认执行确认

当你使用 ghcs 别名并选择“执行命令”**** 时, 会在执行该命令之前要求你确认。 可以更改默认确认。

  1. 请执行以下命令:

    Shell
    gh copilot config
    
  2. 选择用于确认命令执行的默认值

  3. 选择所需的默认设置。

更改使用情况分析

除非选择退出,否则 会将以下格式的有效负载发送到分析系统。 这些数据有助于改进产品。 GitHub 不会查看特定个人或特定查询的数据。

{
  "platform": "darwin",
  "architecture": "arm64",
  "version": "0.3.0-beta",
  "custom_event": "true",
  "event_parent_command": "explain",
  "event_name": "Explain",
  "sha": "089a53215fc4383179869f7f6132ce9d6e58754a",
  "thread_id": "e61d0d08-f6ba-465b-81cf-c30fd9127d70"
}

要选择加入或退出数据集:

  1. 请执行以下命令:

    Shell
    gh copilot config
    
  2. 选择“可选的使用情况分析”。****

  3. 选择所需的默认设置。