This comes out desperation for a lack of filter in the GitHub notifications UI. In cases where a user is involved in several active repositories, managing notifications after a period of inactivity (e.g. coming back from vacation) is extremely painful (see GitHub discussion, since the UI is currently lacking the ability to filter out merged or closed PRs.
This little Go script will go thought the list of unread notifications and mark as read PRs that are either merged or closed. Then you can use the Unread view to help focus only on actionable notifications.
Alternatively, you can even mark notifications as done via --mark-done rather than mark them asread.
Note that this script doesn't do anything related to the unread status of issues and solely focuses on PRs.
-
A working Go environment
-
A valid
GITHUB_TOKENthat has the following permissions:Scope Purpose notifications To read and mark notifications as read repo To access PRs from private repos (if needed)
Build it (needed only once) with:
make build
and then, with a GITHUB_TOKEN env var present, run it using:
./ghn
Example output will look like:
Fetching all GitHub notifications
📦 Page 2 — Total fetched: 73 notifications
✅ Done! Fetched 73 notifications in total.
PR: https://github.com/testorg/testrepo/pull/1234, Title: "PR description", is unmerged and waiting for your review!
PR: https://github.com/testorg/anotherrepo/pull/203, Title: "Another PR description", is unmerged and waiting for your review!
🟡 PR: https://github.com/testorg/anotherrepo/pull/204, Title: "Some other PR description" is merged or closed and notification will be marked as read
🟡 About to mark GH Notification with threadID: "..." as *READ*
🟢 Successfully marked thread as read
...
For each notification change you'll be prompted for y/n, but you can skip by ./ghn --no-prompt (assumes yes).
You can also using make install which will install the tool (by default) under /usr/local/bin/ghn.
The destination path can be modified via the env var DESTINATION_PATH.
gh extension install dliappis/gh-ghngh extension upgrade ghnPlease follow the process in RELEASE.md to create a new release of the extension.