A plugin for the Z shell that posts desktop notifications when a command terminates with a non-zero exit status or when it took more than 30 seconds to complete, if the terminal application is in the background (or the terminal tab is inactive).
- On Mac OS X: Terminal.app or iTerm2;
- On Linux (and possibly other systems): any terminal application should be supported
as
xdotool
andwmctrl
are used to query and modify windows state.
When using the default notifier notifications are posted using
terminal-notifier.app on Mac OS X and notify-send
on other systems.
When using Tmux on Yosemite, reattach-to-user-namespace
is required to
prevent terminal-notifier to hang (see julienXX/terminal-notifier#115
for details).
Just source notify.plugin.zsh.
Use zstyle
in your ~/.zshrc
.
-
Replace the built-in notifier with a custom one at
~/bin/my-notifier
. The custom notifier will receive the notification type (error
orsuccess
) as the first argument, and the notification text (the command) as standard input.zstyle ':notify:*' notifier ~/bin/my-notifier
-
Set a custom title for error and success notifications, when using the built-in notifier.
zstyle ':notify:*' error-title zstyle ':notify:*' success-title
-
Change the notifications icons for failure or success. Any image path or URL (Mac OS only) should work.
zstyle ':notify:*' error-icon "/path/to/error-icon.png" zstyle ':notify:*' success-icon "/path/to/success-icon.png"
Try this. Wow.
-
Set a sound for error and success notifications, when usign the built-in notifier. On Linux you should specify path to audio file.
zstyle ':notify:*' error-sound "Glass" zstyle ':notify:*' success-sound "default"
-
Have the terminal come back to front when the notification is posted.
zstyle ':notify:*' activate-terminal yes
-
Disable setting the urgency hint for the terminal when the notification is posted (Linux only).
zstyle ':notify:*' disable-urgent yes
-
Set a different timeout for notifications for successful commands (notifications for failed commands are posted without accounting for the time it took to complete).
zstyle ':notify:*' command-complete-timeout 15
-
Disable error reporting (or send it somewhere else)
zstyle ':notify:*' error-log /dev/null
Add antigen bundle marzocchi/zsh-notify
to your .zshrc
with your other bundle commands.
Antigen will handle cloning the plugin for you automatically the next time you start zsh. You can also add the plugin to a running zsh with antigen bundle marzocchi/zsh-notify
for testing before adding it to your .zshrc
.
git clone git@github.com:marzocchi/zsh-notify.git ~/.oh-my-zsh/custom/plugins/notify
- Add zsh-notify to your plugin list - edit
~./zshrc
and changeplugins=(...)
toplugins=(... notify)
Note: when cloning, specify the target directory as notify
since Oh-My-Zsh expects the plugin's initialization file to have the same name as it's directory.
Add zgen load marzocchi/zsh-notify
to your .zshrc file in the same function you're doing your other zgen load
calls in.