Don't notify when select commands exit
This commit is contained in:
parent
6678fe0aaf
commit
a9fb5104ac
@ -38,17 +38,33 @@ tmux-dcs-passthrough() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# OSC 9 - Post a notification - supported by iTerm2, kitty, maybe others?
|
# OSC 9 - Post a notification - supported by iTerm2, kitty, WezTerm, others?
|
||||||
notify() {
|
notify() {
|
||||||
tmux-dcs-passthrough '\x1b]9;'"$*"'\x7'
|
tmux-dcs-passthrough '\x1b]9;'"$*"'\x7'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Send a desktop notification when long running commands complete.
|
# 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() {
|
notify-preexec() {
|
||||||
|
if notify-ignore $1; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
notify_command_start=`date +%s`
|
notify_command_start=`date +%s`
|
||||||
notify_command=$1
|
notify_command=$1
|
||||||
}
|
}
|
||||||
|
add-zsh-hook preexec notify-preexec
|
||||||
|
|
||||||
notify-precmd() {
|
notify-precmd() {
|
||||||
if ! [[ -z $notify_command_start ]]; then
|
if ! [[ -z $notify_command_start ]]; then
|
||||||
local notify_command_end=`date +%s`
|
local notify_command_end=`date +%s`
|
||||||
@ -56,9 +72,10 @@ notify-precmd() {
|
|||||||
if [[ $notify_command_time -gt $notify_command_threshold ]]; then
|
if [[ $notify_command_time -gt $notify_command_threshold ]]; then
|
||||||
notify "completed: $notify_command"
|
notify "completed: $notify_command"
|
||||||
fi
|
fi
|
||||||
|
unset notify_command
|
||||||
|
unset notify_command_start
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
add-zsh-hook preexec notify-preexec
|
|
||||||
add-zsh-hook precmd notify-precmd
|
add-zsh-hook precmd notify-precmd
|
||||||
|
|
||||||
# Detect the type and extract an archive file.
|
# Detect the type and extract an archive file.
|
||||||
|
11
zshrc
11
zshrc
@ -231,3 +231,14 @@ esac
|
|||||||
|
|
||||||
command -v wol > /dev/null && \
|
command -v wol > /dev/null && \
|
||||||
alias wakeonlan='wol'
|
alias wakeonlan='wol'
|
||||||
|
|
||||||
|
# Append any aliases to notify_ignore_list if they contain any ignore commands
|
||||||
|
# NOTE: Keep this at the end of ~/.zshrc so all aliases are processed
|
||||||
|
for name in ${(k)aliases}; do
|
||||||
|
cmd=${${${$(alias $name)#${name}=}#\'}#\"}
|
||||||
|
for ignore in $notify_ignore_list; do
|
||||||
|
if [[ "$cmd" = "$ignore"* ]]; then
|
||||||
|
notify_ignore_list+=( $name )
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user