Github Copilot CLI AI for your Terminal

What is Github Copilot CLI

Github Copilot CLI brings the power of Github Copilot to your terminal. Copilot in Github CLI just became generally available.

It’s a command line tool that helps you write commands faster and with fewer errors. You will need a Github Copilot subscription to use this tool.

More information from Github Copilot CLI

Installing Github Copilot CLI

You will need Github CLI installed. Then you can install Github Copilot CLI as an extension.

$ gh extension install github/gh-copilot

Read more about installation

Using Github Copilot CLI

The 2 main actions that Github Copilot CLI supports are suggest and explain. Here is how you would run them.

suggest copilot will take the description of the task you want to complete and will suggest a command for you.

$ gh copilot suggest "Add rbenv ruby to zsh porfile"
? What kind of command can I help you with?
> generic shell command

Suggestion:

  echo 'eval "$(rbenv init -)"' >> ~/.zshrc

explain copilot will explain the command in plain english - this saves time when you don’t want to go through man pages. It’s also useful when you find a command on Google or StackOverflow and want to understand what the command does before running it (highly recommended).

$ gh copilot explain "sudo powermetrics --samplers smc |grep -i \"CPU die temperature\""

Explanation:

  • sudo powermetrics is used to collect power and thermal metrics on macOS.
    • --samplers smc specifies that we want to collect metrics from the System Management Controller (SMC).grep -i "CPU die temperature" searches for the line that contains the case-insensitive string "CPU die temperature" in the output of the powermetrics command.

Remember to escape the quotes in the command you want to explain.

Another example

Overall, I think this can speed up common tasks and help you understand commands better. I’m really excited to see how this tool evolves.