Don't notify when select commands exit

This commit is contained in:
Kenneth Benzie 2024-04-12 22:17:27 +01:00
parent 7aa78e94d1
commit e829a84dde

View File

@ -45,7 +45,32 @@ notify() {
# Send a desktop notification when long running commands complete.
notify_command_threshold=60
notify_ignore_list=(
git
nvim
ssh
sudo
sudoedit
tmux
vi
vim
)
# TODO: append include any of ${(k)aliases} is they contain any of the above
notify-ignore() {
echo "$1"
for ignore in $notify_ignore_list; do
echo "ignore: $ignore"
if [ "$1" = "$ignore"* ]; then
echo "ignored: $1"
# return 0
fi
done
# return 1
}
notify-preexec() {
# if notify-ignore $1; then
# return
# fi
notify_command_start=`date +%s`
notify_command=$1
}
@ -56,6 +81,8 @@ 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