# Note, that you also have to change your compctl for cd and remove
# .
from your cdpath (the later is not necessary but
# recommended).
#
# From: Zoltan Hidvegi <hzoli@cs.elte.hu>
#-----------------------------------------------------------------------
# Start of cdmatch.
# Save in your functions directory and autoload, then do
# compctl -x 'S[/][~][./][../]' -g '*(-/)' - \
# 'n[-1,/], s[]' -K cdmatch -S '/' -- cd pushd
#
# Completes directories for cd, pushd, ... anything which knows about
# cdpath. .
is NOT necessary in your cdpath (in
# fact it's better and faster without it).
local narg pref cdp
read -nc narg
read -Ac pref
cdp=(. $cdpath)
if [[ -o rc_expand_param ]] then
reply=( ${cdp}/${pref[$narg]%$2}*$2(-/DN:t:gs/ /\\\\ /) )
else
reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN:t:gs/ /\\\\ /) )
fi
return
# End of cdmatch.