Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions download_all_github_repos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +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]
```
33 changes: 33 additions & 0 deletions download_all_github_repos/download_all_github_repos.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"