Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pataluc
Forked from ihashacks/notifyosd.zsh
Last active December 11, 2015 20:19
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 pataluc/4654386 to your computer and use it in GitHub Desktop.
Save pataluc/4654386 to your computer and use it in GitHub Desktop.
# end and compare timer, notify-send if needed
function notifyosd-precmd() {
if [ ! -z "$cmd" ]; then
cmd_end=`date +%s`
((cmd_time=$cmd_end - $cmd_start))
fi
if [ ! -z "$cmd" -a $cmd_time -gt 10 ]; then
notify-send -i utilities-terminal -u low "$cmd_basename completed" "\"$cmd\" took $cmd_time seconds"
unset cmd
fi
}
# make sure this plays nicely with any existing precmd
precmd_functions+=( notifyosd-precmd )
# get command name and start the timer
function notifyosd-preexec() {
cmd=$1
cmd_basename=${cmd[(ws: :)1]}
cmd_start=`date +%s`
}
# make sure this plays nicely with any existing preexec
preexec_functions+=( notifyosd-preexec )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment