gh alias set
Turn long commands into shortcuts
gh alias set lets you define your own shorthand for any gh command. Collapse a long, flag-heavy command into a two-letter alias, pass arguments through placeholders, and even wrap arbitrary shell commands so your whole workflow lives behind gh.
gh alias set prs 'pr list --author @me'Syntax
gh alias set <alias> <expansion> [flags]Examples
Alias for your own open PRs
gh alias set prs 'pr list --author @me'Alias with a positional argument
gh alias set co 'pr checkout $1'Bugs alias filtering by label
gh alias set bugs 'issue list --label bug'Wrap a full shell command
gh alias set sync '!git pull && git push'Overwrite an existing alias
gh alias set prs 'pr list --author @me' --clobberOptions & flags
| Flag | What it does |
|---|---|
| -s, --shell | Interpret the expansion as a shell command (also enabled with a leading !). |
| --clobber | Overwrite an existing alias of the same name. |
How to use gh alias set, step by step
- Pick a short name and the command it should expand to.
- Run
gh alias set prs 'pr list --author @me'. - Use placeholders like
$1to accept arguments. - Run it:
gh prs. List all aliases withgh alias list.
Common errors and fixes
X alias named "prs" already exists
Add --clobber to overwrite it, or pick a different name.
expansion does not correspond to a gh command
For non-gh commands, prefix the expansion with ! or add --shell so gh treats it as a shell command.
Related commands
Frequently asked questions
How do I create an alias in GitHub CLI?
Run gh alias set <name> '<expansion>', for example gh alias set prs 'pr list --author @me'. Then run gh prs to use it.
How do I pass arguments to a gh alias?
Use positional placeholders in the expansion: gh alias set co 'pr checkout $1' lets you run gh co 123, which expands to gh pr checkout 123.
Can a gh alias run shell commands?
Yes. Start the expansion with ! or add --shell: gh alias set sync '!git pull && git push' runs the shell command when you call gh sync.