The gh config Command
GitHub CLI configuration works similarly to git config — you can get, set, and list settings.
Setting Values
gh config set <key> <value>
# Examples
gh config set editor vim
gh config set pager "less -R"
gh config set git_protocol ssh
gh config set browser "firefox"
gh config set prompt disabled # Disable interactive promptsGetting Values
gh config get <key>
# Examples
gh config get editor
gh config get git_protocolListing All Settings
gh config listClearing the Cache
gh config clear-cacheConfiguration Keys
| Key | Values | Default | Description |
|---|---|---|---|
git_protocol | https, ssh | https | Default protocol for Git operations |
editor | Any editor command | $GH_EDITOR, $VISUAL, or $EDITOR | Editor for composing text (issues, PRs) |
prompt | enabled, disabled | enabled | Whether to use interactive prompts |
pager | Any pager command | $GH_PAGER, $PAGER, or less | Pager for long output |
http_unix_socket | Socket path | Unix socket for HTTP connections | |
browser | Any browser command | $GH_BROWSER or $BROWSER | Web browser for --web commands |
Host-Specific Configuration
Settings can be scoped to a specific host:
# Set SSH only for github.com, keep HTTPS for enterprise
gh config set git_protocol ssh --host github.com
gh config set git_protocol https --host github.example.comConfiguration Files
All files live in ~/.config/gh/ (override with $GH_CONFIG_DIR).
config.yml
Global settings and aliases:
git_protocol: ssh
editor: vim
prompt: enabled
pager: less
aliases:
co: pr checkout
pvw: pr view --webhosts.yml
Per-host authentication and settings:
github.com:
user: yourname
oauth_token: gho_xxxxxxxxxxxx
git_protocol: sshYou can edit these files directly or use gh config set.
Environment Variables
Environment variables override config file settings. They are especially useful in CI/CD and scripts.
Authentication
| Variable | Purpose |
|---|---|
GH_TOKEN / GITHUB_TOKEN | Auth token for github.com and *.ghe.com |
GH_ENTERPRISE_TOKEN / GITHUB_ENTERPRISE_TOKEN | Auth token for GitHub Enterprise Server |
Host & Repository
| Variable | Purpose |
|---|---|
GH_HOST | Default GitHub hostname when not specified |
GH_REPO | Default repository in [HOST/]OWNER/REPO format |
Editors & Browsers
| Variable | Purpose |
|---|---|
GH_EDITOR | Editor for composing text (highest priority) |
GIT_EDITOR | Fallback editor |
VISUAL | Fallback editor |
EDITOR | Fallback editor (lowest priority) |
GH_BROWSER / BROWSER | Web browser for --web commands |
Output & Display
| Variable | Purpose |
|---|---|
GH_PAGER / PAGER | Terminal pager (e.g., less, bat) |
GH_FORCE_TTY | Force terminal-style output when piping |
GH_MDWIDTH | Max width for markdown rendering |
NO_COLOR | Set to any value to disable ANSI colors |
CLICOLOR | Set to 0 to disable colors |
CLICOLOR_FORCE | Set to non-zero to keep colors when piping |
GH_COLOR_LABELS | Display labels with RGB hex colors |
GLAMOUR_STYLE | Markdown rendering style (dark, light, notty) |
Debugging
| Variable | Purpose |
|---|---|
GH_DEBUG | Set to 1 for verbose output; set to api for HTTP traffic |
Miscellaneous
| Variable | Purpose |
|---|---|
GH_CONFIG_DIR | Override the config directory location |
GH_PROMPT_DISABLED | Disable all interactive prompts |
GH_NO_UPDATE_NOTIFIER | Suppress update-available notices |
GH_NO_EXTENSION_UPDATE_NOTIFIER | Suppress extension update notices |
GH_SPINNER_DISABLED | Replace spinner with text progress |
Example: CI/CD Environment
export GH_TOKEN="ghp_xxxxxxxxxxxx"
export GH_REPO="myorg/myrepo"
export GH_PROMPT_DISABLED=1
export NO_COLOR=1
gh pr create --title "Automated PR" --body "Created by CI"Exercises
- Run
gh config listand review your current settings - Set your preferred editor:
gh config set editor "code --wait" - Switch the default git protocol:
gh config set git_protocol ssh - Open
~/.config/gh/config.ymland inspect the file structure - Try setting
GH_DEBUG=1and run any command to see verbose output