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/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh') diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index e27c6bb76..2a4b43189 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -96,7 +96,6 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then # Append workon_cwd to the chpwd_functions array, so it will be called on cd # http://zsh.sourceforge.net/Doc/Release/Functions.html - if ! (( $chpwd_functions[(I)workon_cwd] )); then - chpwd_functions+=(workon_cwd) - fi + autoload -U add-zsh-hook + add-zsh-hook chpwd workon_cwd fi -- cgit v1.2.3-70-g09d2