1 # Save dirstack history to .zdirs
3 # github.com/grml/grml-etc-core/blob/master/etc/zsh/zshrc#L1547
5 DIRSTACKSIZE=${DIRSTACKSIZE:-20}
6 dirstack_file=${dirstack_file:-${HOME}/.zdirs}
8 if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then
9 dirstack=( ${(f)"$(< $dirstack_file)"} )
10 # "cd -" won't work after login by just setting $OLDPWD, so
11 [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
14 autoload -U add-zsh-hook
15 add-zsh-hook chpwd chpwd_dirpersist
17 if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi
19 my_stack=( ${PWD} ${dirstack} )
20 builtin print -l ${(u)my_stack} >! ${dirstack_file}