Skip to content

Instantly share code, notes, and snippets.

@pybites
Created July 5, 2024 10:24
Show Gist options
  • Save pybites/b2c3be22e3f395cf09f9b2906effec22 to your computer and use it in GitHub Desktop.
Save pybites/b2c3be22e3f395cf09f9b2906effec22 to your computer and use it in GitHub Desktop.
#!/bin/bash
# brew or apt-get install gh jq fzf
CACHE_FILE=~/.gh_repos.json
CACHE_DURATION=$((60*60*24*3)) # 3 days in seconds
if [ ! -f "$CACHE_FILE" ] || [ $(( $(date +%s) - $(stat -c %Y "$CACHE_FILE") )) -ge $CACHE_DURATION ]; then
echo "Refreshing cache..."
gh api user/repos --paginate > "$CACHE_FILE"
fi
# Search and open repository
jq '.[] | select(.permissions.push == true) | .full_name' "$CACHE_FILE" \
| fzf \
| xargs -I{} gh repo view {} --web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment