From 1ba0af650ac575a7d35b10146d2e7a7b3b2e2ae6 Mon Sep 17 00:00:00 2001 From: Jacob Tomaw Date: Tue, 19 Nov 2019 12:47:12 -0500 Subject: Use safer append to hook function arrays (#8406) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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à --- plugins/alias-finder/alias-finder.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins/alias-finder/alias-finder.plugin.zsh') diff --git a/plugins/alias-finder/alias-finder.plugin.zsh b/plugins/alias-finder/alias-finder.plugin.zsh index 6b8fa66ce..caee9b5a3 100644 --- a/plugins/alias-finder/alias-finder.plugin.zsh +++ b/plugins/alias-finder/alias-finder.plugin.zsh @@ -4,7 +4,7 @@ alias-finder() { case $i in -e|--exact) exact=true;; -l|--longer) longer=true;; - *) + *) if [[ -z $cmd ]]; then cmd=$i else @@ -43,4 +43,5 @@ preexec_alias-finder() { fi } -preexec_functions+=(preexec_alias-finder) +autoload -U add-zsh-hook +add-zsh-hook preexec preexec_alias-finder -- cgit v1.2.3-70-g09d2