Last active
October 18, 2025 12:54
-
-
Save BartMassey/356ba118b561deb7168bca52c68836fe to your computer and use it in GitHub Desktop.
Mark all notifications as read ("Ghost notification" remover)
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
| #!/bin/sh | |
| # Mark all notifications as read, including "ghost" notifications. | |
| # Works on Linux, requires a "classic" auth token be present in `~/.github-oauthtoken` | |
| # and also that `gh` is installed. You could presumably use `gh auth login` instead | |
| # if you want to authenticate that way. | |
| # | |
| # Works for me, use at your own risk. | |
| # | |
| # https://github.com/orgs/community/discussions/6874 | |
| # https://docs.github.com/en/rest/activity/notifications?apiVersion=2022-11-28#mark-notifications-as-read | |
| GH_TOKEN="`cat $HOME/.github-oauthtoken`" gh api \ | |
| --method PUT \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| /notifications \ | |
| -f last_read_at="`date -u +%Y-%m-%dT%H:%M:%SZ`" \ | |
| -F read=true |
Author
Excellent! Don't know why I thought permissions were necessary.
It’s a good solution, but if you only want to remove the ghost notifications (and not all notifications), I recommend using:
gh extension install emmanuel-ferdman/gh-gonest
gh gonestSee this original post https://github.com/orgs/community/discussions/6874#discussioncomment-14491447
Author
Yeah gh-gonest looks better offhand.
thanks worked great!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, thanks for posting! :)
The following worked for me (without setting
GH_TOKEN):