Skip to content

Instantly share code, notes, and snippets.

@BartMassey
Last active June 4, 2024 15:11
Show Gist options
  • Save BartMassey/356ba118b561deb7168bca52c68836fe to your computer and use it in GitHub Desktop.
Save BartMassey/356ba118b561deb7168bca52c68836fe to your computer and use it in GitHub Desktop.
Mark all notifications as read ("Ghost notification" remover)
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment