summaryrefslogtreecommitdiff
path: root/plugins/timer/timer.plugin.zsh
diff options
context:
space:
mode:
authorJacob Tomaw <jacob.tomaw@gmail.com>2019-11-19 12:47:12 -0500
committerMarc Cornellà <marc.cornella@live.com>2019-11-19 18:47:12 +0100
commit1ba0af650ac575a7d35b10146d2e7a7b3b2e2ae6 (patch)
tree43f201ed985a63230fae98a20c84118278eb3fc1 /plugins/timer/timer.plugin.zsh
parentd4f32e9f3a6471ce689aa8fb5a9f04e8565bcff6 (diff)
downloadzsh-1ba0af650ac575a7d35b10146d2e7a7b3b2e2ae6.tar.gz
zsh-1ba0af650ac575a7d35b10146d2e7a7b3b2e2ae6.tar.bz2
zsh-1ba0af650ac575a7d35b10146d2e7a7b3b2e2ae6.zip
Use safer append to hook function arrays (#8406)
Use add-zsh-hook to add functions to hooks. That way they won't be added again when doing `source ~/.zshrc` multiple times. Co-authored-by: Marc Cornellà <marc.cornella@live.com>
Diffstat (limited to 'plugins/timer/timer.plugin.zsh')
-rw-r--r--plugins/timer/timer.plugin.zsh5
1 files changed, 3 insertions, 2 deletions
diff --git a/plugins/timer/timer.plugin.zsh b/plugins/timer/timer.plugin.zsh
index 231134e7d..728377c5c 100644
--- a/plugins/timer/timer.plugin.zsh
+++ b/plugins/timer/timer.plugin.zsh
@@ -25,5 +25,6 @@ __timer_display_timer_precmd() {
fi
}
-preexec_functions+=(__timer_save_time_preexec)
-precmd_functions+=(__timer_display_timer_precmd)
+autoload -U add-zsh-hook
+add-zsh-hook preexec __timer_save_time_preexec
+add-zsh-hook precmd __timer_display_timer_precmd