# With arguments, output those files to the recent directory file. # With no arguments, read in the directories from the file into $reply. # # Handles recent-dirs-file and recent-dirs-max styles. emulate -L zsh setopt extendedglob integer max zstyle -s ':chpwd:' recent-dirs-file file || file=${ZDOTDIR:-$HOME}/.chpwd-recent-dirs if (( $# )); then zstyle -s ':chpwd:' recent-dirs-max max || max=20 if (( max > 0 && ${#argv} > max )); then argv=(${argv[1,max]}) fi # Quote on write. # Use $'...' quoting... this fixes newlines and other nastiness. print -rl ${(qqqq)argv} > $file elif [[ -f $file ]]; then typeset -g reply # Unquote on read. reply=(${(Q)${(f)"$(<$file)"}}) else typeset -g reply reply=() fi