1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-23 16:40:24 +02: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

View file

@ -1,6 +1,6 @@
# Add to HOOK the given FUNCTION.
# HOOK is one of chpwd, precmd, preexec, periodic, zshaddhistory,
# zshexit (the _functions subscript is not required).
# zshexit, zsh_directory_name (the _functions subscript is not required).
#
# With -d, remove the function from the hook instead; delete the hook
# variable if it is empty.
@ -15,7 +15,10 @@
emulate -L zsh
local -a hooktypes
hooktypes=(chpwd precmd preexec periodic zshaddhistory zshexit)
hooktypes=(
chpwd precmd preexec periodic zshaddhistory zshexit
zsh_directory_name
)
local opt
local -a autoopts