ghx-cli can be configured through a config file, environment variables, or command-line flags.
Settings are applied in this order (later overrides earlier):
- Config file (
~/.ghx.yaml) - Environment variables
- Command-line flags
Create a config file at ~/.ghx.yaml:
# Authentication
token: "ghp_your_token_here" # GitHub Personal Access Token
# Default context
org: "myorg" # Default organization
user: "myuser" # Default user
# Output settings
format: "table" # Default output format (table, json, yaml)
debug: false # Enable debug output
no-cache: false # Disable caching
# Request settings
timeout: 30s # Request timeout
retries: 3 # Number of retries for failed requestsUse a different config file:
ghx --config /path/to/config.yaml project listAll settings can be configured via environment variables with the GHX_ prefix:
| Variable | Description | Example |
|---|---|---|
GHX_TOKEN |
GitHub token | ghp_xxxx |
GITHUB_TOKEN |
GitHub token (fallback) | ghp_xxxx |
GH_TOKEN |
GitHub token (fallback) | ghp_xxxx |
GHX_ORG |
Default organization | myorg |
GHX_USER |
Default user | myuser |
GHX_FORMAT |
Output format | json |
GHX_DEBUG |
Enable debug | true |
GHX_NO_CACHE |
Disable cache | true |
export GHX_ORG="myorg"
export GHX_FORMAT="json"
export GHX_DEBUG="true"
ghx project list # Uses org=myorg, format=json, debug=trueOverride settings for a single command:
ghx project list --org myorg --format json --debug| Flag | Description | Default |
|---|---|---|
--config |
Config file path | ~/.ghx.yaml |
--token |
GitHub token | - |
--org |
Organization | - |
--user |
User | - |
--format |
Output format | table |
--debug |
Debug output | false |
--no-cache |
Disable cache | false |
Human-readable table format, best for interactive use:
ghx project list --format tableNUMBER TITLE ITEMS UPDATED
1 Sprint 1 42 2024-01-15
2 Backlog 128 2024-01-14
Machine-readable JSON, best for scripting:
ghx project list --format json[
{"number": 1, "title": "Sprint 1", "items": 42, "updated": "2024-01-15"},
{"number": 2, "title": "Backlog", "items": 128, "updated": "2024-01-14"}
]YAML format, useful for configuration files:
ghx project list --format yaml- number: 1
title: Sprint 1
items: 42
- number: 2
title: Backlog
items: 128ghx-cli caches API responses to improve performance. Cache settings:
# In ~/.ghx.yaml
cache:
enabled: true
ttl: 5m # Cache TTL
directory: ~/.ghx/cache# For single command
ghx project list --no-cache
# Via environment
export GHX_NO_CACHE=trueEnable debug mode to see detailed request/response information:
# Via flag
ghx project list --debug
# Via environment
export GHX_DEBUG=trueDebug output includes:
- API requests and responses
- Rate limit information
- Cache hits/misses
- Timing information
Generate shell completion scripts:
# Bash
ghx completion bash > /etc/bash_completion.d/ghx
# Zsh
ghx completion zsh > "${fpath[1]}/_ghx"
# Fish
ghx completion fish > ~/.config/fish/completions/ghx.fish
# PowerShell
ghx completion powershell > ghx.ps1Add to ~/.bashrc:
source <(ghx completion bash)Add to ~/.zshrc:
source <(ghx completion zsh)For managing multiple GitHub accounts, use different config files:
# Work profile
ghx --config ~/.ghx-work.yaml project list
# Personal profile
ghx --config ~/.ghx-personal.yaml project listOr use shell aliases:
# In ~/.bashrc or ~/.zshrc
alias ghx-work='ghx --config ~/.ghx-work.yaml'
alias ghx-personal='ghx --config ~/.ghx-personal.yaml'- Never commit tokens: Add
.ghx.yamlto.gitignore - Use environment variables: Prefer
GITHUB_TOKENover config file - Use GitHub CLI:
gh auth loginis the most secure method - Rotate tokens regularly: Generate new tokens periodically
- Minimal scopes: Only grant required permissions