Skip to content

Instantly share code, notes, and snippets.

@BartMassey
Last active October 18, 2025 12:54
Show Gist options
  • Select an option

  • Save BartMassey/356ba118b561deb7168bca52c68836fe to your computer and use it in GitHub Desktop.

Select an option

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
@cdstanford

Copy link
Copy Markdown

Nice, thanks for posting! :)

The following worked for me (without setting GH_TOKEN):

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

@BartMassey

Copy link
Copy Markdown
Author

Excellent! Don't know why I thought permissions were necessary.

@debug4ever

Copy link
Copy Markdown

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 gonest

See this original post https://github.com/orgs/community/discussions/6874#discussioncomment-14491447

@BartMassey

Copy link
Copy Markdown
Author

Yeah gh-gonest looks better offhand.

@ali0une

ali0une commented Oct 18, 2025

Copy link
Copy Markdown

thanks worked great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment