gh cheatsheet
GitHub’s gh tool.
Get the repo name:
gh repo view --json owner,name --jq '(.owner.login + "/" + .name)'
Files
The config file is in ~/.config/gh/config.yml, including the aliases.
Aliases
(docs)
Make an alias for a gh command. Note that an internal '
is written as '\''
with single quotes around the escaped single quote:
gh alias set owner/repo 'repo view --json owner,name --jq '\''(.owner.login + "/" + .name)'\'''
Make an alias with a shell command:
gh alias set hello --shell 'echo Hello'
See all the aliases:
gh alias list
Save the aliases to share:
gh alias list > my_aliases.yml
gh alias import my_aliases.yml
See what gh sees
Look at the complete JSON to see what’s available
gh COMMAND --json
Get the repo name
This is the command, but I aliased this to owner/repo
:
gh repo view --json owner,name --jq '(.owner.login + "/" + .name)'
gh owner/repo
Labels
The label list --search
seems to be broken, so I made my own label
grepper. I want just plaintext:
gh alias set label-grep --shell 'gh label list --json name --jq .[].name | grep $1'
gh label-grep bug
See all the labels for an issue:
gh alias set issue-labels 'issue view $1 --json labels --jq .labels.[].name'
gh issue-labels ISSUE_NUMBER