Skip to content

Instantly share code, notes, and snippets.

@hamstu
Created March 31, 2025 20:08
Show Gist options
  • Save hamstu/2d1b095449abe31d430dbd197cbba45f to your computer and use it in GitHub Desktop.
Save hamstu/2d1b095449abe31d430dbd197cbba45f to your computer and use it in GitHub Desktop.
Get my need to review PRs (tested only on macOS!)
#!/bin/bash
# Colors
BOLD="\033[1m"
GREEN="\033[0;32m"
YELLOW="\033[1;33m"
BLUE="\033[0;34m"
NC="\033[0m" # No Color
# Helper to print a PR entry
print_pr() {
local number="$1"
local title="$2"
local url="$3"
local author="$4"
local created="$5"
# clickable title with clean color styling
printf "• ${BOLD}${GREEN}"
printf "\e]8;;%s\e\\%s\e]8;;\e\\" "$url" "$title"
printf "${NC}\n"
# info line
printf " ${BLUE}#%s${NC} by ${YELLOW}%s${NC} on %s\n" "$number" "$author" "$created"
# print blank line
printf "\n"
}
# Fetch and format PRs
fetch_prs() {
local state="$1"
echo -e "\n${BOLD}$(echo "$state" | tr '[:lower:]' '[:upper:]') PRs${NC}"
gh pr list \
-S "user-review-requested:@me -reviewed-by:@me state:${state}" \
--json number,title,url,author,createdAt \
--limit 100 |
jq -r '.[] | [.number, .title, .url, .author.login, .createdAt] | @tsv' |
while IFS=$'\t' read -r number title url author created; do
created_fmt=$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$created" "+%b %d, %Y" 2>/dev/null)
print_pr "$number" "$title" "$url" "$author" "$created_fmt"
done
}
# Run the fetchers
fetch_prs "open"
fetch_prs "closed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment