diff options
author | Jacob Tomaw <jacob.tomaw@gmail.com> | 2019-11-19 12:47:12 -0500 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2019-11-19 18:47:12 +0100 |
commit | 1ba0af650ac575a7d35b10146d2e7a7b3b2e2ae6 (patch) | |
tree | 43f201ed985a63230fae98a20c84118278eb3fc1 /plugins/dirpersist | |
parent | d4f32e9f3a6471ce689aa8fb5a9f04e8565bcff6 (diff) | |
download | zsh-1ba0af650ac575a7d35b10146d2e7a7b3b2e2ae6.tar.gz zsh-1ba0af650ac575a7d35b10146d2e7a7b3b2e2ae6.tar.bz2 zsh-1ba0af650ac575a7d35b10146d2e7a7b3b2e2ae6.zip |
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>
Diffstat (limited to 'plugins/dirpersist')
-rw-r--r-- | plugins/dirpersist/dirpersist.plugin.zsh | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/plugins/dirpersist/dirpersist.plugin.zsh b/plugins/dirpersist/dirpersist.plugin.zsh index 616e2c3c6..daadc3850 100644 --- a/plugins/dirpersist/dirpersist.plugin.zsh +++ b/plugins/dirpersist/dirpersist.plugin.zsh @@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD fi -chpwd_functions+=(chpwd_dirpersist) +autoload -U add-zsh-hook +add-zsh-hook chpwd chpwd_dirpersist chpwd_dirpersist() { if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi local -ax my_stack |