Last active
July 28, 2020 00:12
-
-
Save mwthink/2eee4b753d2bf8ce08392be15d11b64a to your computer and use it in GitHub Desktop.
Github Repo Deletion Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Use this to delete github repos easily | |
# Be extremely careful, you can make big mistakes easily with this! | |
# https://github.com/settings/tokens | |
ACCESS_TOKEN="" | |
# List repos | |
GIT_REPOS=$(curl -s \ | |
-H "Authorization: token ${ACCESS_TOKEN}" \ | |
https://api.github.com/user/repos | jq '.[].full_name' | jq -scr '. + ["exit"] | .[]') | |
echo "enter 0 to exit" | |
select REPO in $GIT_REPOS; do | |
if [[ -z ${REPO} ]]; then | |
echo "no good selection" | |
exit 1 | |
fi | |
if [ "${REPO}" == "exit" ]; then | |
echo "Exiting" | |
exit | |
fi | |
curl -s -X DELETE -H "Authorization: token ${ACCESS_TOKEN}" https://api.github.com/repos/${REPO} | |
echo "Deleted ${REPO}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment