chore(alias-finder): Refactor add-zsh-hook part

This commit is contained in:
Roeniss Moon 2025-03-23 22:48:18 +09:00
parent 899af6328b
commit 4fa13eb463
No known key found for this signature in database
GPG Key ID: 9E9AE088DBD537FB

View File

@ -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