Skip to content

Instantly share code, notes, and snippets.

@umrashrf
Last active August 23, 2021 11:11
Show Gist options
  • Save umrashrf/2871ea281a76a4614002 to your computer and use it in GitHub Desktop.
Save umrashrf/2871ea281a76a4614002 to your computer and use it in GitHub Desktop.
Unwatch github repositories in shell
#!/bin/bash
read -p "Github Username: " username;
read -p "Github Token (https://github.com/settings/tokens): " token;
echo "Fetching your repositoreis...";
echo;
repos=$(curl -i -u "$username:$token" "https://api.github.com/user/subscriptions" |\
grep -Po '(?<="full_name": ").*(?=\")');
while [[ $repos = *[!\ ]* ]];
do
for repo in $repos; do
read -p "Unwatch $repo? [y/n] " -n 1 -r;
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo -e " ... \u2714";
curl -X DELETE -u "$username:$token" "https://api.github.com/user/subscriptions/$repo" 2> /dev/null &
echo;
fi
done
repos=$(curl -i -u "$username:$token" "https://api.github.com/user/subscriptions" |\
grep -Po '(?<="full_name": ").*(?=\")');
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment