my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
696 B

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