[metadata] name = "gh-prs" description = "List GitHub PRs for the current repo" requirements = ["gh", "jq"] [source] command = '''gh pr list --state open --limit 100 --json number,title,createdAt,author,labels | jq -r 'sort_by(.createdAt) | reverse | .[] | " \u001b[32m#\(.number)\u001b[39m \(.title) \u001b[33m@\(.author.login)\u001b[39m" + (if (.labels | length) > 0 then " " + ([.labels[] | "\u001b[35m" + .name + "\u001b[39m"] | join(" ")) else "" end)' ''' output = '{strip_ansi|split:#:1|split: :0}' ansi = true [ui] layout = "portrait" [preview] command = '''gh pr view '{strip_ansi|split:#:1|split: :0}' --json number,title,body,state,headRefName,baseRefName,author,createdAt,updatedAt,mergeable,changedFiles,additions,deletions,labels,assignees,reviewDecision,headRepository,headRepositoryOwner | jq -r ' " " + .title, " #" + (.number | tostring), "", " \u001b[36mStatus:\u001b[39m \u001b[32m" + .state + "\u001b[39m " + .baseRefName + " ← " + .headRefName, " \u001b[36mRepo:\u001b[39m \u001b[34m" + (.headRepositoryOwner.login) + "/" + (.headRepository.name) + "\u001b[39m", " \u001b[36mAuthor:\u001b[39m \u001b[33m" + .author.login + "\u001b[39m", " \u001b[36mCreated:\u001b[39m " + (.createdAt | fromdateiso8601 | (now - .) | if . < 3600 then (./60|floor|tostring) + " minutes ago" elif . < 86400 then (./3600|floor|tostring) + " hours ago" else (./86400|floor|tostring) + " days ago" end), " \u001b[36mUpdated:\u001b[39m " + (.updatedAt | fromdateiso8601 | (now - .) | if . < 3600 then (./60|floor|tostring) + " minutes ago" elif . < 86400 then (./3600|floor|tostring) + " hours ago" else (./86400|floor|tostring) + " days ago" end), (if (.labels | length) > 0 then " \u001b[36mLabels:\u001b[39m " + ([.labels[] | "\u001b[35m" + .name + "\u001b[39m"] | join(" ")) else "" end), " \u001b[36mMerge Status:\u001b[39m " + (if .mergeable == "MERGEABLE" then "\u001b[32m✓ Clean\u001b[39m" elif .mergeable == "CONFLICTING" then "\u001b[31m✗ Dirty\u001b[39m" else "\u001b[33m? Unknown\u001b[39m" end), " \u001b[36mChanges:\u001b[39m " + (.changedFiles | tostring) + " files \u001b[32m+" + (.additions | tostring) + "\u001b[39m \u001b[31m-" + (.deletions | tostring) + "\u001b[39m", "", " \u001b[90m────────────────────────────────────────────────────────────\u001b[39m", "", (.body // "")' ''' [actions.open] description = "Open the PR in the browser" command = "gh pr view {strip_ansi|split:#:1|split: :0} --web" mode = "execute" [actions.checkout] description = "Checkout the PR branch locally" command = "gh pr checkout {strip_ansi|split:#:1|split: :0}" mode = "execute" [actions.merge] description = "Merge the selected PR" command = "gh pr merge {strip_ansi|split:#:1|split: :0}" mode = "execute" [actions.diff] description = "View the PR diff" command = "gh pr diff {strip_ansi|split:#:1|split: :0} | less" mode = "execute"