Skip to content

Instantly share code, notes, and snippets.

@naholyr
Created March 3, 2016 14:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naholyr/abf1c7e327d08b9dd3a7 to your computer and use it in GitHub Desktop.
Save naholyr/abf1c7e327d08b9dd3a7 to your computer and use it in GitHub Desktop.
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