Configuration Intermediate

Customize GitHub Copilot CLI to fit your workflow. This lesson covers configuration options, shell aliases for quick access, integration with different shells, environment variables, and privacy settings.

Configuration Options

GitHub Copilot CLI configuration is managed primarily through the GitHub CLI (gh) configuration system and shell-level settings.

Terminal
# View current gh configuration
$ gh config list

# View the Copilot extension version
$ gh extension list

# Update Copilot CLI to the latest version
$ gh extension upgrade gh-copilot
Setting Command Description
Editor gh config set editor vim Set default editor for gh operations
Protocol gh config set git_protocol ssh Set git protocol (https or ssh)
Browser gh config set browser firefox Set default browser for auth flows
Prompt gh config set prompt enabled Enable or disable interactive prompts

Setting Default Shell

Copilot CLI detects your shell automatically, but you can influence its suggestions by specifying the shell type in your requests.

Terminal
# Be explicit about shell in your requests
$ gh copilot suggest "list all environment variables in bash"
$ gh copilot suggest "list all environment variables in PowerShell"
$ gh copilot suggest "list all environment variables in fish shell"

# The suggestions will differ based on the shell you mention:
# bash:       env  or  printenv
# PowerShell: Get-ChildItem Env:
# fish:       set -x
Shell Detection: Copilot CLI attempts to detect your current shell environment. On macOS/Linux it typically detects bash or zsh, and on Windows it detects PowerShell or Command Prompt. Mentioning the shell explicitly in your query ensures the most relevant suggestion.

Alias Setup for Quick Access

Typing gh copilot suggest every time can be verbose. Set up shell aliases to make it faster.

Bash / Zsh Aliases

~/.bashrc or ~/.zshrc
# GitHub Copilot CLI aliases
alias cs='gh copilot suggest'
alias ce='gh copilot explain'

# Type-specific aliases
alias css='gh copilot suggest -t shell'
alias csg='gh copilot suggest -t git'
alias csgh='gh copilot suggest -t gh'

After adding aliases, reload your shell configuration:

Terminal
# Reload bash
$ source ~/.bashrc

# Reload zsh
$ source ~/.zshrc

# Now you can use short aliases
$ cs "find large files"
$ ce "tar -xzf archive.tar.gz"
$ csg "squash last 3 commits"

GitHub CLI Aliases

You can also use gh alias to create shortcuts within the GitHub CLI itself:

Terminal
# Create gh aliases
$ gh alias set cs 'copilot suggest'
$ gh alias set ce 'copilot explain'

# Now you can use:
$ gh cs "find large files"
$ gh ce "tar -xzf archive.tar.gz"

# List all aliases
$ gh alias list

Integration with Shell

Bash Integration

Add Copilot CLI functions to your ~/.bashrc for a more integrated experience:

~/.bashrc
# Copilot suggest function with default shell type
copilot_suggest() {
  local type="shell"
  if [ "$1" = "git" ] || [ "$1" = "gh" ]; then
    type="$1"
    shift
  fi
  gh copilot suggest -t "$type" "$*"
}
alias ask='copilot_suggest'

# Usage:
# ask find all large files          (defaults to shell type)
# ask git squash last 3 commits     (uses git type)
# ask gh list my pull requests      (uses gh type)

Zsh Integration

For Zsh users, add similar functions to ~/.zshrc:

~/.zshrc
# Copilot CLI aliases
alias cs='gh copilot suggest'
alias ce='gh copilot explain'

# Quick explain last command
explain_last() {
  local last_cmd=$(fc -ln -1)
  gh copilot explain "$last_cmd"
}
alias why='explain_last'

# Usage: run a command, then type 'why' to explain it

PowerShell Integration

PowerShell Profile ($PROFILE)
# GitHub Copilot CLI functions for PowerShell

# Suggest command
function Invoke-CopilotSuggest {
  param([string]$Description)
  gh copilot suggest $Description
}
Set-Alias -Name cs -Value Invoke-CopilotSuggest

# Explain command
function Invoke-CopilotExplain {
  param([string]$Command)
  gh copilot explain $Command
}
Set-Alias -Name ce -Value Invoke-CopilotExplain

# Usage:
# cs "list all running services"
# ce "Get-Process | Where-Object { $_.CPU -gt 100 }"

To edit your PowerShell profile:

PowerShell
# Open profile in default editor
$ notepad $PROFILE

# Or create it if it doesn't exist
$ New-Item -Path $PROFILE -ItemType File -Force

Environment Variables

Several environment variables can influence GitHub CLI and Copilot CLI behavior:

Variable Description Example
GH_TOKEN GitHub authentication token (overrides gh auth login) export GH_TOKEN=ghp_xxxx
GH_HOST GitHub hostname (for GitHub Enterprise) export GH_HOST=github.mycompany.com
GH_EDITOR Editor to use for gh commands export GH_EDITOR=vim
GH_BROWSER Browser to use for auth and web commands export GH_BROWSER=firefox
NO_COLOR Disable color output export NO_COLOR=1
HTTP_PROXY HTTP proxy for network requests export HTTP_PROXY=http://proxy:8080
HTTPS_PROXY HTTPS proxy for network requests export HTTPS_PROXY=http://proxy:8080
~/.bashrc
# GitHub CLI environment variables
export GH_EDITOR="code --wait"
export GH_BROWSER="firefox"

# For GitHub Enterprise
# export GH_HOST="github.mycompany.com"

# For corporate proxy
# export HTTPS_PROXY="http://proxy.corp.com:8080"

Privacy Settings

Understanding what data Copilot CLI sends and how to manage your privacy is important.

What Data is Sent:
  • Your natural language query (the description you type)
  • The command you want explained (for explain)
  • Your shell environment type (bash, zsh, PowerShell, etc.)
  • Your operating system type
What is NOT Sent:
  • Your file contents or source code
  • Your environment variables or secrets
  • Your command history
  • Files in your working directory

Managing Data and Privacy

Terminal
# Review your GitHub Copilot settings
# Visit: https://github.com/settings/copilot

# Check your authentication scopes
$ gh auth status

# Revoke access if needed
$ gh auth logout
Sensitive Information: Avoid including sensitive data like passwords, API keys, or personal information in your Copilot CLI queries. While queries are encrypted in transit, it is best practice to keep sensitive data out of AI prompts.

Organization Policies

If you use GitHub Copilot through a Business or Enterprise plan, your organization may have additional policies:

  • Usage policies - Your admin can enable or disable Copilot CLI for your organization
  • Data retention - Organization settings may control how long suggestion data is retained
  • IP indemnity - Enterprise plans may include IP indemnity provisions
  • Audit logs - Enterprise admins can view Copilot usage in audit logs

Try It Yourself

Customize your Copilot CLI setup:

  1. Add the cs and ce aliases to your shell configuration file
  2. Reload your shell and test the aliases work
  3. Try creating a custom function like explain_last
  4. Set up a gh alias for your most common Copilot CLI usage pattern
  5. Review your privacy settings at github.com/settings/copilot

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.