diff --git a/modules/directory/README.md b/modules/directory/README.md index 47c1bc20..59f24b99 100644 --- a/modules/directory/README.md +++ b/modules/directory/README.md @@ -24,6 +24,15 @@ Aliases - `d` prints the contents of the directory stack. - `1 ... 9` changes the directory to the **n** previous one. +Settings +-------- + +### Persist Dirstack + +To persist the dirstack across sessions, add the following to *zpreztorc*: + + zstyle ':prezto:module:directory' persist-dirstack 'yes' + Authors ------- diff --git a/modules/directory/init.zsh b/modules/directory/init.zsh index 47191dfe..de1cdd91 100644 --- a/modules/directory/init.zsh +++ b/modules/directory/init.zsh @@ -28,3 +28,19 @@ unsetopt CLOBBER # Do not overwrite existing files with > and >>. alias d='dirs -v' for index ({1..9}) alias "$index"="cd +${index}"; unset index + +if (is-at-least 4.1) \ + && zstyle -t ':prezto:module:directory' persist-dirstack +then + if [[ -f ~/.zdirs ]] && [[ ${#dirstack[*]} -eq 0 ]]; then + echo "\n" >> ~/.zdirs + dirstack=( ${(uf)"$(< ~/.zdirs)"//"$HOME"[[:space:]]/} ) + fi + + function _persist_dirstack { + dirs -pl >! ~/.zdirs + } + + autoload -Uz add-zsh-hook + add-zsh-hook chpwd _persist_dirstack +fi diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index e93ac6bf..7af70e42 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -41,6 +41,13 @@ zstyle ':prezto:load' pmodule \ # Set the query found color. # zstyle ':prezto:module:autosuggestions:color' found '' +# +# Directory +# + +# Persist dirstack +# zstyle ':prezto:module:directory' persist-dirstack 'yes' + # # Editor #