Rename reset_tracking and move function

This commit is contained in:
Michael Aquilina 2019-07-17 21:39:08 +01:00
parent bf73292fd0
commit 890236ced9
No known key found for this signature in database
GPG key ID: 636066730B056BD1

View file

@ -7,15 +7,6 @@ export AUTO_NOTIFY_IGNORE=(
"vim" "nvim" "less" "more" "man" "tig" "watch" "git commit" "top" "htop" "ssh" "nano" "vim" "nvim" "less" "more" "man" "tig" "watch" "git commit" "top" "htop" "ssh" "nano"
) )
function _reset_tracking() {
# Command start time in seconds since epoch
unset AUTO_COMMAND_START
# Full command that the user has executed after alias expansion
unset AUTO_COMMAND_FULL
# Command that the user has executed
unset AUTO_COMMAND
}
function _auto_notify_message() { function _auto_notify_message() {
local command="$1" local command="$1"
local elapsed="$2" local elapsed="$2"
@ -68,7 +59,7 @@ function _auto_notify_send() {
# Empty tracking so that notifications are not # Empty tracking so that notifications are not
# triggered for any commands not run (e.g ctrl+C when typing) # triggered for any commands not run (e.g ctrl+C when typing)
_reset_tracking _auto_notify_reset_tracking
} }
function _auto_notify_track() { function _auto_notify_track() {
@ -77,6 +68,15 @@ function _auto_notify_track() {
AUTO_COMMAND_START="$(date +"%s")" AUTO_COMMAND_START="$(date +"%s")"
} }
function _auto_notify_reset_tracking() {
# Command start time in seconds since epoch
unset AUTO_COMMAND_START
# Full command that the user has executed after alias expansion
unset AUTO_COMMAND_FULL
# Command that the user has executed
unset AUTO_COMMAND
}
function disable_auto_notify() { function disable_auto_notify() {
add-zsh-hook -D preexec _auto_notify_track add-zsh-hook -D preexec _auto_notify_track
add-zsh-hook -D precmd _auto_notify_send add-zsh-hook -D precmd _auto_notify_send
@ -89,5 +89,5 @@ function enable_auto_notify() {
autoload -Uz add-zsh-hook autoload -Uz add-zsh-hook
_reset_tracking _auto_notify_reset_tracking
enable_auto_notify enable_auto_notify