Last active
June 11, 2025 13:34
-
-
Save ange-daumal/acaaa70cb68675512b1226c3a1cee6d6 to your computer and use it in GitHub Desktop.
list_requested_prs.5m.sh: xbar version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" | |
# <xbar.title>PR Reviews</xbar.title> | |
# <xbar.version>v1.0</xbar.version> | |
# <xbar.author>Ange DAUMAL</xbar.author> | |
# <xbar.desc>Show open PRs that request your review.</xbar.desc> | |
# <xbar.dependencies>gh, bash</xbar.dependencies> | |
# <xbar.refreshTime>5m</xbar.refreshTime> | |
REPOS=("algolia/python" "algolia/go") | |
PR_COUNT=0 | |
PR_LINES=() | |
for REPO in "${REPOS[@]}"; do | |
while IFS=$'\t' read -r number title url; do | |
# Exclude PRs starting with "chore(deps):" | |
if [[ "$title" =~ ^chore\(deps\): ]]; then | |
continue | |
fi | |
# Check if it's a draft | |
is_draft=$(gh pr view "$number" --repo "$REPO" --json isDraft --jq '.isDraft') | |
# Add PR to the list | |
if [[ "$is_draft" == "true" ]]; then | |
PR_LINES+=("[DRAFT] $title | href=$url") | |
else | |
PR_LINES+=("$title | href=$url") | |
fi | |
((PR_COUNT++)) | |
done < <( | |
gh pr list \ | |
--repo "$REPO" \ | |
--state open \ | |
--search "review-requested:@me" \ | |
--json number,title,url \ | |
--jq '.[] | [.number, .title, .url] | @tsv' | |
) | |
done | |
# Show PR count in the menu bar | |
echo "PRs: $PR_COUNT" | |
# Dropdown content | |
echo "---" | |
if [[ $PR_COUNT -eq 0 ]]; then | |
echo "No PRs to review 🎉" | |
else | |
for line in "${PR_LINES[@]}"; do | |
echo "$line" | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment