Don't notify when select commands exit

This commit is contained in:
2024-04-12 22:17:27 +01:00
parent 6678fe0aaf
commit a9fb5104ac
2 changed files with 31 additions and 3 deletions

View File

@@ -38,17 +38,33 @@ tmux-dcs-passthrough() {
fi
}
# OSC 9 - Post a notification - supported by iTerm2, kitty, maybe others?
# OSC 9 - Post a notification - supported by iTerm2, kitty, WezTerm, others?
notify() {
tmux-dcs-passthrough '\x1b]9;'"$*"'\x7'
}
# Send a desktop notification when long running commands complete.
notify_command_threshold=60
notify_command_threshold=5
notify_ignore_list=( git nvim ssh sudo sudoedit tmux vi vim )
notify-ignore() {
for ignore in $notify_ignore_list; do
if [[ "$1" = "$ignore"* ]]; then
return 0
fi
done
return 1
}
notify-preexec() {
if notify-ignore $1; then
return
fi
notify_command_start=`date +%s`
notify_command=$1
}
add-zsh-hook preexec notify-preexec
notify-precmd() {
if ! [[ -z $notify_command_start ]]; then
local notify_command_end=`date +%s`
@@ -56,9 +72,10 @@ notify-precmd() {
if [[ $notify_command_time -gt $notify_command_threshold ]]; then
notify "completed: $notify_command"
fi
unset notify_command
unset notify_command_start
fi
}
add-zsh-hook preexec notify-preexec
add-zsh-hook precmd notify-precmd
# Detect the type and extract an archive file.