How to Sort Pull Requests by Merge Time with GitHub CLI and PowerShell

The aim of this page📝 is nothing less than the apotheosis of PowerShell :)

Pavol Kutaj
2 min readMar 10, 2023
apotheosis of PowerShell terminal, baroque,

The story goes

  • I’m working in the Infrastructure-as-Code environment
  • Sometimes the change (often that reads chaos:) is introduced
  • I need to see if there’s a recent pull request behind that
  • I am convinced that one should not switch contexts (leave terminal, home sweet home) for such a triviality, so github CLI comes to help
  • So there is a command to list the last 10 merged PR
gh pr list --state merged --limit 10
  • The default view, however, tells you then the PR was opened, which is not what I want
  • For customization, you’d need to use --json flag but that gives you UGH which is not even sorted!
  • You could go down the rabbit hole of gh help formatting but after spending 15 minutes tinkering with --jq and --template flags, I realized that I am embedded within Powershell and that should give me all that I need
  • Here it comes — as a table + sorted with mergedAt timestamp
  • from now on, happily living in $profile as lpr available — as it should! — only three keystrokes away
> DONE <



Pavol Kutaj

Today I Learnt | Infrastructure Support Engineer at with a passion for cloud infrastructure/terraform/python/docs. More at