1
0
mirror of synced 2025-12-20 10:28:40 -05:00
Files
docs/content/copilot/using-github-copilot/using-github-copilot-in-the-command-line.md
Copilot ec7bb4d9bb Move Copilot variables from product.yml to copilot.yml (#55832)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: hubwriter <54933897+hubwriter@users.noreply.github.com>
Co-authored-by: hubwriter <hubwriter@github.com>
Co-authored-by: felicitymay <1877141+felicitymay@users.noreply.github.com>
Co-authored-by: Felix Guntrip <stevecat@github.com>
Co-authored-by: Joe Clark <31087804+jc-clark@users.noreply.github.com>
Co-authored-by: Ebonsignori <17055832+Ebonsignori@users.noreply.github.com>
2025-06-02 11:35:54 +01:00

55 lines
3.1 KiB
Markdown

---
title: Using GitHub Copilot in the command line
intro: 'You can use {% data variables.product.prodname_copilot_short %} with the {% data variables.product.prodname_cli %} to get suggestions and explanations for the command line.'
versions:
feature: copilot-in-the-cli
topics:
- Copilot
- CLI
shortTitle: Use Copilot in the CLI
redirect_from:
- /copilot/github-copilot-in-the-cli/using-github-copilot-in-the-cli
- /copilot/using-github-copilot/using-github-copilot-in-the-cli
---
## Prerequisites
* **Access to {% data variables.product.prodname_copilot %}**. See [AUTOTITLE](/copilot/about-github-copilot/what-is-github-copilot#getting-access-to-copilot).
* **{% data variables.product.prodname_cli %} installed**. {% data reusables.cli.cli-installation %}
* **{% data variables.copilot.copilot_cli_short %} extension installed**. See [AUTOTITLE](/copilot/github-copilot-in-the-cli/installing-github-copilot-in-the-cli).
If you have access to {% data variables.product.prodname_copilot %} via your organization or enterprise, you cannot use {% data variables.copilot.copilot_cli_short %} if your organization owner or enterprise administrator has disabled {% data variables.copilot.copilot_cli_short %}. See [AUTOTITLE](/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-github-copilot-features-in-your-organization/managing-policies-for-copilot-in-your-organization).
## Getting command explanations
To ask {% data variables.copilot.copilot_cli_short %} to explain a command, run `gh copilot explain` followed by the command that you want explained. For example:
```shell copy
gh copilot explain "sudo apt-get"
```
## Getting command suggestions
To ask {% data variables.copilot.copilot_cli_short %} to suggest a command, run `gh copilot suggest` followed by the command that you want. For example:
```shell copy
gh copilot suggest "Undo the last commit"
```
{% data variables.copilot.copilot_cli_short %} will start an interactive session to get more information about what you want.
If you choose the **Execute command** option after {% data variables.copilot.copilot_cli_short %} suggests a command, {% data variables.copilot.copilot_cli_short %} will copy the command to your clipboard and exit the interactive session. Then you can manually paste the command into your CLI.
If you want {% data variables.copilot.copilot_cli_short %} to be able to execute commands on your behalf, you must set up the `ghcs` alias. See [AUTOTITLE](/copilot/github-copilot-in-the-cli/configuring-github-copilot-in-the-cli#setting-up-aliases).
## Sharing feedback
To send feedback to {% data variables.product.company_short %} about the quality of a suggestion, select the **Rate response** option in {% data variables.copilot.copilot_cli_short %}.
You can also open an issue in the [{% data variables.copilot.copilot_cli_short %} extension repository](https://github.com/github/gh-copilot).
## Further reading
* [{% data variables.copilot.copilot_cli_short %} extension README](https://github.com/github/gh-copilot?tab=readme-ov-file)
* [AUTOTITLE](/copilot/github-copilot-in-the-cli/configuring-github-copilot-in-the-cli)