git plugin and zsh-notify: silent status alert configuration
0 reputation · 14 Jun 2026, 02:12 UTC
0 reputation · 14 Jun 2026, 02:12 UTC
Goal: configure the Oh My Zsh git plugin to render repository status in the prompt while preventing the zsh-notify plugin from emitting desktop alerts for every command exit. The git plugin provides a built‑in prompt that can display branch name and change indicators, but its interaction with zsh-notify hooks can cause unintended pop‑ups, especially when exit‑code filtering is not finely tuned. Oh My Zsh 5.x and 6.x may handle precmd and preexec hooks differently, so compatibility across versions adds another layer of uncertainty.
Which hook combination suppresses zsh‑notify pop‑ups while still exposing git status? Can exit‑code thresholds be set so that only non‑zero returns trigger notifications? Is there a version‑agnostic configuration pattern that works consistently between Oh My Zsh 5.x and 6.x?
Load the git plugin before zsh-notify, then remove zsh-notify’s precmd hook and use an exit‑code filter so notifications appear only on failures. The same pattern works on Oh My Zsh 5.x and 6.x.
precmd.preexec and emits a notification in precmd.add-zsh-hook to register hooks; order is determined by load order and explicit add/remove calls.Every command triggers a desktop pop‑up because zsh-notify’s precmd runs after the git plugin’s precmd and does not check the exit status by default. Removing that hook stops the pop‑ups while keeping the git status visible.
~/.zshrc, list the plugins in the desired order:
plugins=(git zsh-notify)precmd hook:
# Notify only on non‑zero exit
export NOTIFY_THRESHOLD=0
# Remove the precmd hook so it does not fire on every prompt redraw
add-zsh-hook -d precmd notify
# Keep preexec for exit‑code capture
# If your fork uses a different hook name, inspect with:
# functions | grep -A2 '^notify'precmd() {
local exit_code=$?
if [[ $exit_code -ne 0 ]]; then
notify
fi
}functions | grep precmd and confirm notify is not listed.false) and verify that a notification appears only if the optional failure trigger was added.Which exact fork of zsh-notify you are using matters because variable names for exit‑code filtering differ between releases. If you can identify the fork (e.g. the original zsh-notify or a community fork), the configuration variable may be NOTIFY_THRESHOLD or another similarly named option. Knowing the exact repo lets us give a more precise variable name.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.