Skip to content

Instantly share code, notes, and snippets.

@stand-sure
Created May 2, 2025 14:19
Show Gist options
  • Save stand-sure/cc54afbad110606a348c8ae537de77f7 to your computer and use it in GitHub Desktop.
Save stand-sure/cc54afbad110606a348c8ae537de77f7 to your computer and use it in GitHub Desktop.
Lists open PRs under a root directory where the URL matches a pattern (useful for filtering to just one org)
#!/usr/bin/env bash
# open-prs.sh
__gh=/opt/homebrew/bin/gh
__jq=/opt/homebrew/bin/jq
while IFS= read -r -d '' dir
do
dir=$(dirname "$dir")
cd "$dir" || continue
__check=$("${__gh}" pr list --json title,url 2>/dev/null | "${__jq}" '.[] | select(.url | test("__REPLACE__THIS__")).title')
if [[ -n "$__check" ]]; then
pwd
"${__gh}" pr list --json title,url 2>/dev/null | "${__jq}" '.[] | select(.url | test("__REPLACE__THIS__")).title'
fi
cd - > /dev/null || exit
done < <(find . -name '.git' -type d -print0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment