Created
June 3, 2021 19:15
-
-
Save codegoalie/45d09a5a0a9fef27dd097eaa5e578ed6 to your computer and use it in GitHub Desktop.
(Re)watch all of your own repos using gh cli
This file contains hidden or 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
$ gh api graphql --paginate -f query=' | |
query($endCursor: String) { | |
viewer { | |
repositories(first: 100, after: $endCursor) { | |
nodes { nameWithOwner } | |
pageInfo { | |
hasNextPage | |
endCursor | |
} | |
} | |
} | |
} | |
' | \ | |
jq '.data.viewer.repositories.nodes|map(.nameWithOwner)[]' | \ | |
sed 's/"//g' | \ | |
xargs -I % gh api --silent -X PUT repos/%/subscription -f subscribed=true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I accidentally had auto-watch team set and joined an organization with almost a thousand repos...
I went to the Watching page page and after individually unwatching like 100 repos, I decided to Unwatch all. Then I wanted to rewatch just my own repos. Turns out the gh cli has an
api
command to use the GitHub API directly...It's not everyday I get to compose such a one-liner so I wanted to share it.