Skip to content

Instantly share code, notes, and snippets.

@jadiunr
Created July 27, 2021 02:01

Revisions

  1. jadiunr created this gist Jul 27, 2021.
    16 changes: 16 additions & 0 deletions get_all_own_repositories.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/bin/bash
    # Usage: ./get_all_own_repositories.sh <your github token>
    # Requirements: jq, ghq

    TOKEN=$1
    PAGE=1;
    while true; do
    REPOS=`curl -sS -H "Authorization: Bearer $TOKEN" -H 'Accept: application/vnd.github.v3+json' https://api.github.com/user/repos?page=$PAGE | jq -r .[].ssh_url`
    if [ -z "$REPOS" ]; then
    exit
    fi
    for REPO in $REPOS; do
    ghq get $REPO
    done
    PAGE=$((PAGE += 1))
    done