summaryrefslogtreecommitdiff
path: root/plugins/dirpersist
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dirpersist')
-rw-r--r--plugins/dirpersist/README.md9
-rw-r--r--plugins/dirpersist/dirpersist.plugin.zsh4
2 files changed, 12 insertions, 1 deletions
diff --git a/plugins/dirpersist/README.md b/plugins/dirpersist/README.md
new file mode 100644
index 000000000..9880bc563
--- /dev/null
+++ b/plugins/dirpersist/README.md
@@ -0,0 +1,9 @@
+# Dirpersist plugin
+
+This plugin keeps a running tally of the previous 20 unique directories in the $HOME/.zdirs file. When you cd to a new directory, it is prepended to the beginning of the file.
+
+To use it, add `dirpersist` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... dirpersist)
+```
diff --git a/plugins/dirpersist/dirpersist.plugin.zsh b/plugins/dirpersist/dirpersist.plugin.zsh
index 88d1129d4..daadc3850 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() {
+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
my_stack=( ${PWD} ${dirstack} )