I have updated the tutorial to adjust for changes in CLI commands and added a section about how to upgrade GitHub CLI and GitHub Copilot CLI.
In a previous blog post, I explained how to install GitHub Copilot on lxplus machines. In this post, I will explain how to install and handle updates for GitHub Copilot CLI on lxplus machines. GitHub Copilot CLI is a command-line tool that allows you to ask coding-related questions directly in your terminal. This is useful for quick assistance without switching to other interfaces.
The installation is similar to the GitHub CLI case, where we don't have root permissions and need to manually install the binaries in our home directory. This tutorial also covers how to handle updates easily.
Prerequisites
- Access to a lxplus CERN machine.
- Basic familiarity with terminal commands.
Setup
Step 1: Downloading GitHub CLI
Begin by downloading the latest GitHub CLI (gh
) binary. You can always check the GitHub CLI releases page for the most recent version. Here, we use version 2.46.0
, but make sure to replace it with the latest available version when you follow these steps.
LATEST_GH_VERSION=
This script dynamically fetches the latest release version of GitHub CLI. If you prefer, you can still manually visit the releases page and download the version you want.
Step 2: Extracting the Archive
Once the download completes, extract the archive and remove the tar.gz
file.
Step 3: Installing GitHub CLI
Move the gh
binary to a directory in your path, such as $HOME/local/bin
.
Ensure that $HOME/local/bin
is in your PATH by adding export PATH="$HOME/local/bin:$PATH"
to your .bashrc
or .zshrc
file if needed.
Step 4: Verifying the Installation
To verify that gh
is correctly installed, run:
Step 5: Installing GitHub Copilot CLI Extension
With gh
installed, you can now install the GitHub Copilot CLI extension:
This installs the GitHub Copilot CLI extension, which allows you to use Copilot in your terminal. You can now run:
For more information, run:
That's it! You have successfully installed GitHub Copilot CLI on your lxplus machine. You can now use Copilot in your terminal to get code suggestions and completions.
Handling Updates for GitHub CLI and Copilot CLI
To keep GitHub CLI and the Copilot extension up to date, follow these steps:
Step 1: Automating GitHub CLI Updates
You can add an alias or script to check for updates and automatically download the latest version of GitHub CLI.
This script checks the installed version against the latest version available on GitHub and updates the binary if needed.
Step 2: Automating GitHub Copilot CLI Extension Updates
For updating the GitHub Copilot CLI extension, you can use the following command to ensure that the extension is up-to-date:
You can also add this to a function for easier use:
Step 3: Adding Update Commands to .bashrc
(Optional)
To make it easier to manage updates, you can add aliases to your .bashrc
or .zshrc
:
Now, you can simply run gh-update
or copilot-update
to keep both tools up to date.