mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-08-25 21:35:42 +02:00
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>
This commit is contained in:
committed by
Marc Cornellà
parent
d4f32e9f3a
commit
1ba0af650a
@@ -20,9 +20,10 @@ function precmd_update_git_vars() {
|
||||
fi
|
||||
}
|
||||
|
||||
chpwd_functions+=(chpwd_update_git_vars)
|
||||
precmd_functions+=(precmd_update_git_vars)
|
||||
preexec_functions+=(preexec_update_git_vars)
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd chpwd_update_git_vars
|
||||
add-zsh-hook precmd precmd_update_git_vars
|
||||
add-zsh-hook preexec preexec_update_git_vars
|
||||
|
||||
|
||||
## Function definitions
|
||||
|
Reference in New Issue
Block a user