How to list all open GitHub pull requests and select one on the command line (#snippet)

GitHub released the GitHub CLI a year ago. The tools covers a wide range of GitHub functionality including creating releases, listing issues and pull requests and way more.
I have to admit, I haven’t extensively used the GitHub CLI …


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis

GitHub released the GitHub CLI a year ago. The tools covers a wide range of GitHub functionality including creating releases, listing issues and pull requests and way more.

I have to admit, I haven't extensively used the GitHub CLI since its release because standard git does the job just fine for me most of the time. But when I used it, I liked it a lot. Today I came across the post Scripting with the GitHub CLI and it includes many productivity tips to use GitHub more productively on the command line. One snippet helping out with pull request handling caught my eye particularly.

How to use fzf to list all and select one pull requests interactively

Like many other well-designed CLIs, GitHub's command line interface also includes the possibility of setting aliases for specific commands. The blog post shares a handy snippet to automatically fetch all open PRs and select one with fuzzy matching using fzf. If you haven't played around with fzf, you definitely should. It's fantastic!

$ gh alias set co --shell 'id="$(gh pr list -L100 | fzf | cut -f1)"; [ -n "$id" ] && gh pr checkout "$id"'

$ gh co

The above snippet creates a co alias (it's stored at ~/.config/gh/config.yml) to make PR handling more convenient. See it in action below. ?


Reply to Stefan


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis


Print Share Comment Cite Upload Translate Updates
APA

Stefan Judis | Sciencx (2021-03-19T23:00:00+00:00) How to list all open GitHub pull requests and select one on the command line (#snippet). Retrieved from https://www.scien.cx/2021/03/19/how-to-list-all-open-github-pull-requests-and-select-one-on-the-command-line-snippet/

MLA
" » How to list all open GitHub pull requests and select one on the command line (#snippet)." Stefan Judis | Sciencx - Friday March 19, 2021, https://www.scien.cx/2021/03/19/how-to-list-all-open-github-pull-requests-and-select-one-on-the-command-line-snippet/
HARVARD
Stefan Judis | Sciencx Friday March 19, 2021 » How to list all open GitHub pull requests and select one on the command line (#snippet)., viewed ,<https://www.scien.cx/2021/03/19/how-to-list-all-open-github-pull-requests-and-select-one-on-the-command-line-snippet/>
VANCOUVER
Stefan Judis | Sciencx - » How to list all open GitHub pull requests and select one on the command line (#snippet). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/03/19/how-to-list-all-open-github-pull-requests-and-select-one-on-the-command-line-snippet/
CHICAGO
" » How to list all open GitHub pull requests and select one on the command line (#snippet)." Stefan Judis | Sciencx - Accessed . https://www.scien.cx/2021/03/19/how-to-list-all-open-github-pull-requests-and-select-one-on-the-command-line-snippet/
IEEE
" » How to list all open GitHub pull requests and select one on the command line (#snippet)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2021/03/19/how-to-list-all-open-github-pull-requests-and-select-one-on-the-command-line-snippet/. [Accessed: ]
rf:citation
» How to list all open GitHub pull requests and select one on the command line (#snippet) | Stefan Judis | Sciencx | https://www.scien.cx/2021/03/19/how-to-list-all-open-github-pull-requests-and-select-one-on-the-command-line-snippet/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.