Be More Productive With Github CLI Alias
As a developer I spend a fair amount of time each day making and reviewing pull requests. I’ve also been trying harder to do more within the terminal these days because I find there to be a wealth of productivity from a single interface. Github recently released their own CLI tool (in beta at the time of this writing) and I’m really finding a lot of value in it.
You can check out the repository for the CLI here: https://github.com/cli/cli
There’s good documentation on installing the CLI in the repo’s README file so I won’t offer too much help with that. Since I’m currently working on a Windows machine I opted to try out installing via Scoop, which seems pretty cool so far.
Aliases
I’m really finding a lot of productivity from the CLI’s alias
features. Essentially an alias
is just a shortcut you can define for another command in the CLI.
Here are a few of my aliases that help me out most days:
Checkout the branch for a given pull request by number or url
Alias: co
CLI Command: pr checkout
Usage: gh co 123
How to add: gh alias set co 'pr checkout'
List issues
Alias: issues
Command: issue list
Usage: gh issues
How to add: gh alias set issues 'issue list'
Create a new pull request for the current branch
Pushes the current branch to the remote and then launches the “new pull request” page in the browser
Alias: newpr
Command: pr create -w
Usage: gh newpr
How to add: gh alias set newpr 'pr create -w'
List pull requests assigned to me
Alias: prme
Command: pr list -a <your github username>
Usage: gh prme
How to add: gh alias set prme 'pr list -a <your github username>'
List all open pull requests
Alias: prs
Command: pr list
Usage: gh prs
How to add: gh alias set prs 'pr list'
View a pull request by number in the browser
Alias: pv
Command: pr view $1 -w
Usage: gh pv 123
How to add: gh alias set pv 'pr view $1 -w'
Final Thoughts
As I mentioned, the CLI is currently still in beta (I’m running v0.11.1
) but so far I’m very pleased with the features and the productivity gains it’s offered. I’ve really only spent time with the pr
commands so I can’t speak to the gist
, issue
, or repo
commands but I’m sure there’s a lot of value there too, particularly for cloning and trying things out. I look forward to seeing where this goes and offer big thanks to the folks working on the CLI for helping me save just a bit more time in my days.