Skip to content

Instantly share code, notes, and snippets.

@naholyr naholyr/.zshrc
Created Mar 3, 2016

Embed
What would you like to do?
Notify when a zsh command ends in a shell not currently focused
# Requires zsh
# Requires xdotool
the_command="?????"
preexec()
{
if [ "x$TTY" != "x" ]; then
the_command="$2"
fi
}
precmd()
{
local the_status=$?
if [ "$the_command" != "?????" -a "x$TTY" != "x" ]; then
# window title should still be the current command, or we switched window
local window_title=$(xdotool getwindowfocus getwindowname)
if [ "$the_command" != "$window_title" ]; then
local face="face-smile"
if [ "$code_command" != "0" ]; then
face="face-sad"
fi
notify-send --expire-time=2000 --icon=$face "'$the_command' terminated (code $the_status)"
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.