-if zstyle -T ':grml:chpwd:dirstack' filter-on-load; then
- for i in "${dirstack[@]}"; do
- if ! grml_dirstack_filter "$i"; then
- GRML_PERSISTENT_DIRSTACK=(
- "${GRML_PERSISTENT_DIRSTACK[@]}"
- $i
- )
- fi
- done
-else
- GRML_PERSISTENT_DIRSTACK=( "${dirstack[@]}" )
+ if [[ -f ${DIRSTACKFILE} ]]; then
+ # Enabling NULL_GLOB via (N) weeds out any non-existing
+ # directories from the saved dir-stack file.
+ dirstack=( ${(f)"$(< $DIRSTACKFILE)"}(N) )
+ # "cd -" won't work after login by just setting $OLDPWD, so
+ [[ -d $dirstack[1] ]] && cd -q $dirstack[1] && cd -q $OLDPWD
+ fi
+
+ if zstyle -t ':grml:chpwd:dirstack' filter-on-load; then
+ for i in "${dirstack[@]}"; do
+ if ! grml_dirstack_filter "$i"; then
+ GRML_PERSISTENT_DIRSTACK=(
+ "${GRML_PERSISTENT_DIRSTACK[@]}"
+ $i
+ )
+ fi
+ done
+ else
+ GRML_PERSISTENT_DIRSTACK=( "${dirstack[@]}" )
+ fi