Skip to content

Support aliases deeper than top level, e.g. gh pr co #1303

Description

@issyl0

Describe the feature or problem you’d like to solve

I type gh pr checkout many 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.

Proposed solution

Add an alias for co to the pr_checkout command.

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!

Additional context

Thanks for building the gh tool!

Activity

  1. mislav commented on Jul 1, 2020

    @mislav
    Contributor

    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.

    $ gh alias set co 'pr checkout'
    $ gh co 123
    

    In fact, I believe that we ship with this alias as default for new users who are installing GitHub CLI.

  2. issyl0 commented on Jul 1, 2020

    @issyl0
    ContributorAuthor

    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).

  3. mislav commented on Jul 1, 2020

    @mislav
    Contributor

    @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?

  4. issyl0 commented on Jul 1, 2020

    @issyl0
    ContributorAuthor

    Thanks for your responses. This is fine to close. If gh co still seems weird in a week or two, I can keep my local change to support gh pr co.

  5. pataquets commented on Feb 23, 2021

    @pataquets

    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.

  6. mislav commented on Feb 23, 2021

    @mislav
    Contributor

    That's a good point! Reopening

  7. reopened this on Feb 23, 2021
  8. changed the title [-]Alias `gh pr checkout` to `gh pr co`[/-] [+]Support aliases deeper than top level, e.g. `gh pr co`[/+] on Feb 23, 2021
  9. added
    coreThis issue is not accepting PRs from outside contributors
    on Mar 8, 2021
  10. mathieutu commented on Apr 19, 2022

    @mathieutu

    The same here.
    I was trying to add gh pr browse for pr view -w like we have gh browse.

  11. cravend commented on Jun 21, 2022

    @cravend

    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.

  12. self-assigned this
    on Mar 13, 2023
  13. assigned and unassigned on May 15, 2023
  14. koppor commented on Aug 23, 2025

    @koppor

    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.
  15. BagToad commented on Aug 25, 2025

    @BagToad
    Member

    @koppor I'd say you should make a new issue for that. We could always add new default aliases, but need to discuss it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLI

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions