Get URL Of The Last Pull Request With Powershell

Pavol Kutaj
Jul 10, 2021

--

The aim of this playbook馃弫 is to show obtaining the URL of the last pull request with PowerShell and GitHub CLI.

1. steps

  • navigate to the repo
  • run get-lastPRurl
  • you get the URL clipped

2. CODE

function get-lastPRurl {
$prn = gh pr list --state all --limit 1 --json number | ConvertFrom-Json
$prurl = gh pr view $prn.number --json url | ConvertFrom-Json
$prurl.url | clip
Write-Host $prurl.url clipped -Foregroundcolor DarkCyan
}

--

--

Pavol Kutaj

Today I Learnt | Infrastructure Support Engineer at snowplow.io with a passion for cloud infrastructure/terraform/python/docs. More at https://pavol.kutaj.com