Using GitHub Copilot for CLI on Windows
GitHub Copilot for CLI is an NPM package which you can install and use on Windows if you have Node.js 16 or newer on your machine. However, the official setup only makes the commands available in zsh and bash. This means that you can only use it in WSL, but fortunately, there are also ways to make it work in PowerShell.
To use GitHub Copilot for CLI, you need to
- have an active GitHub Copilot subscription,
- get access to GitHub Copilot for CLI after signing up on the waitlist.
Once you get access, you'll be notified with an email. And that's when you can start with the installation procedure.
WSL
Open your WSL terminal and install Node.js 16 or newer, preferably using Node Version Manager:
- Install Node Version Manager first:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
- Restart your WSL terminal to make it available.
- Use it to install the LTS Node.js version (18 at the time of writing):
nvm install --lts
Now you're ready to install GitHub Copilot for CLI:
- Globally install the NPM package:
npm install -g @githubnext/github-copilot-cli
- Authenticate with your GitHub account:
github-copilot-cli auth
To make the alias commands permanently available, you need to edit your .bashrc
file. I recommend using Visual Studio Code with the WSL extension.
- Open
.bashrc
in Visual Studio Code:code ~/.bashrc
- Add the following command to the bottom of the file:
eval "$(github-copilot-cli alias -- "$0")"
- Save the file and restart the terminal.
You're now ready to use the GitHub for CLI commands whenever you open your WSL terminal.
PowerShell
First, install Node.js 16 or newer, preferably using NVM for Windows.
Then, open your PowerShell Terminal and install GitHub Copilot for CLI:
- Globally install the NPM package:
npm install -g @githubnext/github-copilot-cli
- Authenticate with your GitHub account:
github-copilot-cli auth
There are no official alias commands for PowerShell, so you'll have to settle with a 3rd party alternative. I decided to use the PSGitHubCopilotCLI PowerShell module. To make it work:
- Install the PowerShell module:
Install-Module -Name PSGitHubCopilotCLI -AllowPrerelease
- Open your
$PROFILE
file in Visual Studio Code:code $PROFILE
- Import the PowerShell module at the bottom of the file:
Import-Module -Name PSGitHubCopilotCLI
- Save the file and restart the terminal.
You're now ready to use the GitHub for CLI commands whenever you open your PowerShell terminal.