You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support aliases deeper than top level, e.g. gh pr co #1303
Describe the feature or problem you’d like to solve
I type gh pr checkoutmany times a day. Typing checkout is long. I have shell aliases for git checkout: gco. That muscle memory could carry over to gh pr checkout too, with the gh pr co command alias.
I'd like to think that this affects many people using gh pr checkout: not just me. But I've not done any research to verify that thought.
I considered some alternatives, like the existing tab completions. While they do work as intended, gh pr c<tab><tab> and gh pr ch<tab> take three keypresses, and are different from the "usual" co abbreviation for checkout.
I've got the change ready to go locally - but as per the contributing guide, I'm submitting an issue first to see if there's an appetite for this!
gh alias set co 'pr checkout' works - thanks, @mislav. I didn't realise alias set was a thing. 😳
I did try out gh alias set 'pr co' 'pr checkout', which doesn't seem to work. But I understand that keeping the pr namespacing is perhaps not the preferred way (even though it makes more sense to me as co operates on PRs in this case).
@issyl0 You're right, right now aliases are only supported at "top-level" and not nested under a command such as pr. We could potentially support nested ones too, but I don't see why someone would create a 2-word alias when they can create a 1-word one.
Do you feel that this can be closed or that we should keep it open as a feature request?
Same here. In my usage case, I've tried to define gh issue mine as issue list --author pataquets. Ended up implementing it as issue.mine, but supporting deeper aliases would open some meaningful shortcuts for common switches as described. @mislav: I would like to ask this issue to be left open to keep track of it, in case sometime in the future it could be implemented, although I understand it might not be a priority now.
Just wanted to drop my use-case in this issue (I didn't see it when I opened my own!).
I have gh go aliased to gh repo view --web, but I'd like to extend that to other commands (e.g. gh pr go for gh pr view --web). I could do something like gh prgo (one word) but it's more natural to me to think of go = view --web.
Is this the place to ask for gh pr co {num} out of the box.
In the default setting one needs to omit pr, which is confusing (because it is not consistent why one needs to write checkout in one place and co in another place although both terms have the same effect)
$ gh pr co 13280
unknown command"co"for"gh pr"
$ gh co 13280
remote: Enumerating objects: 178, done.
Activity
mislav commentedon Jul 1, 2020
Hi, thanks for explaining how you're using gh!
Would it be an option for you to create a gh alias for
pr checkout? E.g.In fact, I believe that we ship with this alias as default for new users who are installing GitHub CLI.
issyl0 commentedon Jul 1, 2020
gh alias set co 'pr checkout'works - thanks, @mislav. I didn't realisealias setwas a thing. 😳I did try out
gh alias set 'pr co' 'pr checkout', which doesn't seem to work. But I understand that keeping theprnamespacing is perhaps not the preferred way (even though it makes more sense to me ascooperates on PRs in this case).mislav commentedon Jul 1, 2020
@issyl0 You're right, right now aliases are only supported at "top-level" and not nested under a command such as
pr. We could potentially support nested ones too, but I don't see why someone would create a 2-word alias when they can create a 1-word one.Do you feel that this can be closed or that we should keep it open as a feature request?
issyl0 commentedon Jul 1, 2020
Thanks for your responses. This is fine to close. If
gh costill seems weird in a week or two, I can keep my local change to supportgh pr co.pataquets commentedon Feb 23, 2021
Same here. In my usage case, I've tried to define
gh issue mineasissue list --author pataquets. Ended up implementing it asissue.mine, but supporting deeper aliases would open some meaningful shortcuts for common switches as described.@mislav: I would like to ask this issue to be left open to keep track of it, in case sometime in the future it could be implemented, although I understand it might not be a priority now.
mislav commentedon Feb 23, 2021
That's a good point! Reopening
[-]Alias `gh pr checkout` to `gh pr co`[/-][+]Support aliases deeper than top level, e.g. `gh pr co`[/+]mathieutu commentedon Apr 19, 2022
The same here.
I was trying to add
gh pr browseforpr view -wlike we havegh browse.cravend commentedon Jun 21, 2022
Just wanted to drop my use-case in this issue (I didn't see it when I opened my own!).
I have
gh goaliased togh repo view --web, but I'd like to extend that to other commands (e.g.gh pr goforgh pr view --web). I could do something likegh prgo(one word) but it's more natural to me to think ofgo=view --web.koppor commentedon Aug 23, 2025
Is this the place to ask for
gh pr co {num}out of the box.In the default setting one needs to omit
pr, which is confusing (because it is not consistent why one needs to writecheckoutin one place andcoin another place although both terms have the same effect)BagToad commentedon Aug 25, 2025
@koppor I'd say you should make a new issue for that. We could always add new default aliases, but need to discuss it.