From 084792b829657cdf516799e43f89c0b8c22f4ab8 Mon Sep 17 00:00:00 2001 From: xiao Date: Mon, 3 Aug 2015 22:10:24 -0700 Subject: [PATCH 1/3] Don't clobber chpwd --- plugins/dirhistory/dirhistory.plugin.zsh | 4 +++- plugins/last-working-dir/last-working-dir.plugin.zsh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index d101cfcae..a2faa9ee4 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -49,7 +49,9 @@ function push_future() { } # Called by zsh when directory changes -function chpwd() { +typeset -ga chpwd_functions +chpwd_functions+='chpwd_dirhistory' +function chpwd_dirhistory() { push_past $PWD # If DIRHISTORY_CD is not set... if [[ -z "${DIRHISTORY_CD+x}" ]]; then diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index 75041f08e..708ae4f74 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -8,7 +8,9 @@ mkdir -p $ZSH_CACHE_DIR cache_file="$ZSH_CACHE_DIR/last-working-dir" # Updates the last directory once directory is changed. -function chpwd() { +typeset -ga chpwd_functions +chpwd_functions+='chpwd_last_working_dir' +function chpwd_last_working_dir() { # Use >| in case noclobber is set to avoid "file exists" error pwd >| "$cache_file" } From aac552362917fc729c80d191dd387016e39f97a0 Mon Sep 17 00:00:00 2001 From: xiao Date: Mon, 3 Aug 2015 22:58:29 -0700 Subject: [PATCH 2/3] Additional chpwd clobbering fix for dirpersist --- plugins/dirpersist/dirpersist.plugin.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/dirpersist/dirpersist.plugin.zsh b/plugins/dirpersist/dirpersist.plugin.zsh index 88d1129d4..e4590afc6 100644 --- a/plugins/dirpersist/dirpersist.plugin.zsh +++ b/plugins/dirpersist/dirpersist.plugin.zsh @@ -11,7 +11,9 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD fi -chpwd() { +typeset -ga chpwd_functions +chpwd_functions+='chpwd_dirpersist' +chpwd_dirpersist() { if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi local -ax my_stack my_stack=( ${PWD} ${dirstack} ) From cddfc3b038d821ddb6d0e81410675ffaeb11cac9 Mon Sep 17 00:00:00 2001 From: "xiao.fan" Date: Tue, 4 Aug 2015 15:07:47 -0700 Subject: [PATCH 3/3] style fixes --- plugins/dirhistory/dirhistory.plugin.zsh | 3 +-- plugins/dirpersist/dirpersist.plugin.zsh | 3 +-- plugins/last-working-dir/last-working-dir.plugin.zsh | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index a2faa9ee4..0209981e3 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -49,8 +49,7 @@ function push_future() { } # Called by zsh when directory changes -typeset -ga chpwd_functions -chpwd_functions+='chpwd_dirhistory' +chpwd_functions+=(chpwd_dirhistory) function chpwd_dirhistory() { push_past $PWD # If DIRHISTORY_CD is not set... diff --git a/plugins/dirpersist/dirpersist.plugin.zsh b/plugins/dirpersist/dirpersist.plugin.zsh index e4590afc6..616e2c3c6 100644 --- a/plugins/dirpersist/dirpersist.plugin.zsh +++ b/plugins/dirpersist/dirpersist.plugin.zsh @@ -11,8 +11,7 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD fi -typeset -ga chpwd_functions -chpwd_functions+='chpwd_dirpersist' +chpwd_functions+=(chpwd_dirpersist) chpwd_dirpersist() { if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi local -ax my_stack diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index 708ae4f74..c458464ce 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -8,8 +8,7 @@ mkdir -p $ZSH_CACHE_DIR cache_file="$ZSH_CACHE_DIR/last-working-dir" # Updates the last directory once directory is changed. -typeset -ga chpwd_functions -chpwd_functions+='chpwd_last_working_dir' +chpwd_functions+=(chpwd_last_working_dir) function chpwd_last_working_dir() { # Use >| in case noclobber is set to avoid "file exists" error pwd >| "$cache_file"