DEV Community

Cover image for Getting Started with GitHub Copilot in the CLI🚀

Getting Started with GitHub Copilot in the CLI🚀

Kedasha on November 17, 2023

If you've ever used the terminal, you know the struggle of trying to remember a command, the fear of breaking your system with a random command you...
Collapse
 
daveparr profile image
Dave Parr

Great wrote up. Had GH installed for a while but hadn't spotted this. I started building a related AI thing called starpilot a few weeks ago because I wanted a way to discover hidden gems in my GitHub stars, but maybe they're going to scoop me on it with tools like this!

Collapse
 
ladykerr profile image
Kedasha GitHub

oh that's soo cool! Starpilot looks promising Would love to have you on open source fridays if you wanna show it off!

Collapse
 
daveparr profile image
Dave Parr

I was inspired by what Simon said about blogging in this ep I watched this morning and spent some time this afternoon dusting off the old dev.to blog and wrote up a post on starpilot :)

Collapse
 
daveparr profile image
Dave Parr • Edited

Sure, what is OpenSource Fridays?

EDIT: Ha, just found what you mean. answer is still sure :)

Collapse
 
weldingtorchhh profile image
Welding-Torch

To add gcp(or any term) as your github copilot alias on Windows command prompt, do the following:

  1. Open Notepad and type in doskey gcp=gh copilot $*
  2. Save the file as aliased.cmd in C:\Windows
  3. Open regedit.msc and paste Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor into the address bar
  4. Right-click and select New String Value. Name the key AutoRun and paste C:\Windows\aliases.cmd as the key's value.

@ladykerr Maybe you can add this to the article, since Windows currently has 70% marketshare for Desktop users. I think it would be super helpful.

Collapse
 
weldingtorchhh profile image
Welding-Torch

Update: Actually don't do that because even though it works you see the alias being set every time you run cmd. Instead use bgreco.net/alias/, and after installing it type alias gcp=gh copilot in command prompt.

That's it.

Collapse
 
gurucubano profile image
Matthias

Hello,
I have to use a company managed account for GitHub Copilot and it works fine in IntelliJ and even in vim. For gh-copilot I get:

$ gh extension install github/gh-copilot
$ gh auth status
github.com
  ✓ Logged in to github.com account apitzm_xxxx (keyring)
  - Active account: true
  - Git operations protocol: https
  - Token: gho_************************************
  - Token scopes: 'gist', 'read:org', 'repo', 'workflow'

$ gh copilot -h
Your AI command line copilot.

Usage:
  copilot [command]

Examples:

$ gh copilot suggest "Install git"
$ gh copilot explain "traceroute github.com"


Available Commands:
  alias       Generate shell-specific aliases for convenience
  config      Configure options
  explain     Explain a command
  suggest     Suggest a command
...

But it seems that our accounts are missing something:

$ gh copilot suggest -t shell "Convert SVG to PNG and resize"

✗ Error: User is not authorized to use this Copilot feature
Enter fullscreen mode Exit fullscreen mode

What we do miss here in my/our GitHub account?

Collapse
 
vulwsztyn profile image
Artur Mostowski • Edited

If you've ever used the terminal, you know the struggle of trying to remember a command, the fear of breaking your system with a random command you found on the interwebs or the frustration of trying to find the right command to do what you want.

That must be the most junior paragraph ever written.

This "article" is also literally about 2 subcommands.

How do you think is your "article" better than much more concise docs docs.github.com/en/copilot/github-...?

On the other hand I love the screebshots/gifs and that it is relatively "in-depth".

Collapse
 
ladykerr profile image
Kedasha GitHub

This blog is not intended to be better than the official docs. It is a guide on how to use copilot in the cli. Feel free to download the tool and ask it more advanced questions. This blog was written for devs across all experience levels in mind.