diff --git a/utilities/utilities.plugin.zsh b/utilities/utilities.plugin.zsh index 357b65d..d0d5d0a 100644 --- a/utilities/utilities.plugin.zsh +++ b/utilities/utilities.plugin.zsh @@ -43,6 +43,24 @@ notify() { tmux-dcs-passthrough '\x1b]9;'"$*"'\x7' } +# Send a desktop notification when long running commands complete. +notify_command_threshold=60 +notify-preexec() { + notify_command_start=`date +%s` + notify_command=$1 +} +notify-precmd() { + if ! [[ -z $notify_command_start ]]; then + local notify_command_end=`date +%s` + local notify_command_time=$(($notify_command_end - $notify_command_start)) + if [[ $notify_command_time -gt $notify_command_threshold ]]; then + notify "completed: $notify_command" + fi + fi +} +add-zsh-hook preexec notify-preexec +add-zsh-hook precmd notify-precmd + # Detect the type and extract an archive file. extract() { if [ -f $1 ]; then