Published at
Updated at
Reading time
1min

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

gh co command showing how to list and choose a GitHub pull request

If you enjoyed this article...

Join 5.5k readers and learn something new every week with Web Weekly.

Web Weekly — Your friendly Web Dev newsletter
Reply to this post and share your thoughts via good old email.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles