From 1cc49ab64216f096ae26cb0a6ffe7a121e19e3b5 Mon Sep 17 00:00:00 2001 From: glitchdawg Date: Fri, 28 Oct 2022 04:48:41 +0530 Subject: [PATCH 1/2] scripts to download all public repos from a github account --- download_all_github_repos/README.md | 1 + .../download_all_github_repos.sh | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 download_all_github_repos/README.md create mode 100755 download_all_github_repos/download_all_github_repos.sh diff --git a/download_all_github_repos/README.md b/download_all_github_repos/README.md new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/download_all_github_repos/README.md @@ -0,0 +1 @@ + diff --git a/download_all_github_repos/download_all_github_repos.sh b/download_all_github_repos/download_all_github_repos.sh new file mode 100755 index 0000000..0a29088 --- /dev/null +++ b/download_all_github_repos/download_all_github_repos.sh @@ -0,0 +1,33 @@ +download_repos() { + user_name="$1" + temp_dir=$(mktemp -d -q /tmp/repo_archive_XXXXXX) + if [ $? -ne 0 ]; then + echo "$0: Can't create a temp dir!" + exit 1 + fi + + echo "Using the following temp dir: $temp_dir" + cd "$temp_dir" && + virtualenv env && + source env/bin/activate && + pip install ghcloneall && + ghcloneall --init --user "$user_name" && + ghcloneall && + deactivate && + cd ~ + destination="$user_name""_repo_archive.tar" + tar -cvf "$destination" "$temp_dir" + rm -rf "$temp_dir" + echo "All repositories of $user_name have been written to $destination" +} + +main() { + if [[ $# -ne 1 ]]; then + echo "Usage: download_all_github_repos.sh [github_username]" + exit 1 + fi + + download_repos "$1" +} + +main "$@" From 6afa9e92d45292c21d445440e73f761c58a71874 Mon Sep 17 00:00:00 2001 From: glitchdawg Date: Fri, 28 Oct 2022 04:52:19 +0530 Subject: [PATCH 2/2] added a README.md file to download_all_github_repos.sh --- download_all_github_repos/README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/download_all_github_repos/README.md b/download_all_github_repos/README.md index 8d1c8b6..7ff7c05 100644 --- a/download_all_github_repos/README.md +++ b/download_all_github_repos/README.md @@ -1 +1,12 @@ - +To run this script, open the terminal in the directory where the script is located by + +```bash +cd BashScripts +``` + +and type the following command: + +```bash +chmod u+x download_all_github_repos.sh +./download_all_github_repos.sh [github username] +```