Created
March 3, 2016 14:41
-
-
Save naholyr/abf1c7e327d08b9dd3a7 to your computer and use it in GitHub Desktop.
Notify when a zsh command ends in a shell not currently focused
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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