From 4fa13eb463971dd070fe54236bd47c5846b8ba44 Mon Sep 17 00:00:00 2001 From: Roeniss Moon Date: Sun, 23 Mar 2025 22:48:18 +0900 Subject: [PATCH] chore(alias-finder): Refactor add-zsh-hook part --- plugins/alias-finder/alias-finder.plugin.zsh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/alias-finder/alias-finder.plugin.zsh b/plugins/alias-finder/alias-finder.plugin.zsh index 5fdfbc835..3ed1dbb0a 100644 --- a/plugins/alias-finder/alias-finder.plugin.zsh +++ b/plugins/alias-finder/alias-finder.plugin.zsh @@ -51,12 +51,14 @@ alias-finder() { done } +# add hook to run alias-finder before each command preexec_alias-finder() { - # TODO: Remove backward compatibility (other than zstyle form) - zstyle -t ':omz:plugins:alias-finder' autoload && alias-finder $1 || if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then - alias-finder $1 - fi + alias-finder "$1" } - -autoload -U add-zsh-hook -add-zsh-hook preexec preexec_alias-finder +if zstyle -t ':omz:plugins:alias-finder' autoload ; then + autoload -Uz alias-finder + add-zsh-hook preexec preexec_alias-finder +elif [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then # TODO: remove this legacy style support + autoload -Uz alias-finder + add-zsh-hook preexec preexec_alias-finder +fi