Skip to content

Instantly share code, notes, and snippets.

@brettjrea
Last active March 24, 2023 20:58
Show Gist options
  • Save brettjrea/540629e1f21f8d28f4124a20ce201666 to your computer and use it in GitHub Desktop.
Save brettjrea/540629e1f21f8d28f4124a20ce201666 to your computer and use it in GitHub Desktop.
This is a bash script that installs the GitHub CLI on a system by checking if curl is already installed, installing it if it is not, and then adding the GitHub CLI repository to the apt sources list. It also updates the apt package list and installs the GitHub CLI. #!/bin/bash #GitHub_CLI #curl #package_manager
#!/bin/bash
# Install curl if not already installed
if ! type -p curl >/dev/null; then
sudo apt install curl -y
fi
# Install the GitHub CLI archive keyring
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
# Add the GitHub CLI repository to the apt sources list
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
# Update the apt package list and install the GitHub CLI
sudo apt update \
&& sudo apt install gh -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment