You are helping the user install and authenticate the GitHub CLI tool.
Installs GitHub CLI and configures authentication with optional SSH setup and shell completion.
/plugin marketplace add danielrosehill/linux-desktop-plugin/plugin install lan-manager@danielrosehillYou are helping the user install and authenticate the GitHub CLI tool.
Check if gh is already installed:
which gh
gh --version
If already installed and authenticated:
gh auth status
Install GitHub CLI (if not installed):
Method 1: Using official repository (recommended):
# Add the GPG key
sudo mkdir -p -m 755 /etc/apt/keyrings
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
# Add the repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
# Install
sudo apt update
sudo apt install gh
Method 2: Using snap:
sudo snap install gh
Method 3: Using Homebrew (if installed):
brew install gh
Verify installation:
gh --version
which gh
Authenticate with GitHub:
Interactive authentication (recommended):
gh auth login
This will prompt for:
Via web browser (easiest):
Via token:
Verify authentication:
gh auth status
Should show:
Configure gh settings:
Set default editor:
gh config set editor vim
# or
gh config set editor nano
# or
gh config set editor code # VS Code
Set default protocol:
gh config set git_protocol ssh
# or
gh config set git_protocol https
View all config:
gh config list
Set up SSH key (if using SSH protocol):
# Generate SSH key if needed
ssh-keygen -t ed25519 -C "your_email@example.com"
# Add to ssh-agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# Add to GitHub
gh ssh-key add ~/.ssh/id_ed25519.pub --title "My Ubuntu Desktop"
# Or copy public key to GitHub manually
cat ~/.ssh/id_ed25519.pub
Test GitHub connectivity:
# Test SSH connection
ssh -T git@github.com
# Test gh CLI
gh repo list
gh auth status
Configure git to use gh for credentials:
gh auth setup-git
This configures git to use gh as a credential helper.
Show basic gh commands:
Repository operations:
gh repo create - Create a repositorygh repo clone <repo> - Clone a repositorygh repo view - View repository detailsgh repo list - List your repositoriesgh repo fork - Fork a repositoryPull requests:
gh pr create - Create a pull requestgh pr list - List pull requestsgh pr view <number> - View a PRgh pr checkout <number> - Checkout a PRgh pr merge <number> - Merge a PRgh pr review <number> - Review a PRIssues:
gh issue create - Create an issuegh issue list - List issuesgh issue view <number> - View an issuegh issue close <number> - Close an issueWorkflows:
gh workflow list - List workflowsgh workflow view <workflow> - View workflowgh workflow run <workflow> - Trigger a workflowgh run list - List workflow runsgh run view <run> - View a runGists:
gh gist create <file> - Create a gistgh gist list - List gistsgh gist view <gist> - View a gistSet up shell completion:
For bash:
gh completion -s bash > ~/.gh-completion.bash
echo 'source ~/.gh-completion.bash' >> ~/.bashrc
source ~/.bashrc
For zsh:
gh completion -s zsh > ~/.gh-completion.zsh
echo 'source ~/.gh-completion.zsh' >> ~/.zshrc
source ~/.zshrc
Configure multiple accounts (if needed):
# Add another account
GH_HOST=github.com gh auth login
# Switch between accounts
gh auth switch
Set up aliases (optional):
gh alias set pv 'pr view'
gh alias set co 'pr checkout'
gh alias set bugs 'issue list --label=bug'
List aliases:
gh alias list
Authenticate with GitHub Enterprise (if applicable):
gh auth login --hostname github.example.com
Troubleshooting common issues:
Permission denied:
gh auth statusgh auth loginSSH issues:
ssh -T git@github.comgh ssh-key addssh-add -lRate limiting:
gh api rate_limitUpdate gh:
sudo apt update
sudo apt upgrade gh
# or
brew upgrade gh
# or
sudo snap refresh gh
Advanced configuration:
Custom API endpoint:
gh config set api_endpoint https://api.github.com
Disable prompts:
gh config set prompt disabled
Configure pager:
gh config set pager less
Security best practices:
Provide workflow examples:
Create a repo and push:
mkdir my-project
cd my-project
git init
echo "# My Project" > README.md
git add README.md
git commit -m "Initial commit"
gh repo create my-project --public --source=. --push
Fork and clone:
gh repo fork owner/repo --clone
Create PR from current branch:
gh pr create --title "My changes" --body "Description of changes"
Report findings: Summarize: