1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-27 16:50:58 +01:00

users/15864: turn zsh_directory_name into a hook

This commit is contained in:
Peter Stephenson 2011-03-11 16:32:07 +00:00
parent cc69ecfb9e
commit f2dca9e155
9 changed files with 148 additions and 62 deletions

View file

@ -5,4 +5,5 @@ _cdr
chpwd_recent_add
chpwd_recent_dirs
chpwd_recent_filehandler
zsh_directory_name_cdr
'

View file

@ -0,0 +1,25 @@
if [[ $1 = n ]]; then
if [[ $2 = <-> ]]; then
# Recent directory
typeset -ga reply
autoload -Uz cdr
cdr -r
if [[ -n ${reply[$2]} ]]; then
reply=(${reply[$2]})
return 0
else
reply=()
return 1
fi
fi
elif [[ $1 = c ]]; then
if [[ $PREFIX = <-> || -z $PREFIX ]]; then
typeset -a keys values
values=(${${(f)"$(cdr -l)"}/ ##/:})
keys=(${values%%:*})
_describe -t dir-index 'recent directory index' \
values keys -V unsorted -S']'
return
fi
fi
return 1