1# Start of cdmatch. 2# Save in your functions directory and autoload, then do 3# compctl -x 'S[/][~][./][../]' -g '*(-/)' - \ 4# 'n[-1,/], s[]' -K cdmatch -S '/' -- cd pushd 5# 6# Completes directories for cd, pushd, ... anything which knows about cdpath. 7# You do not have to include `.' in your cdpath. 8# 9# It works properly only if $ZSH_VERSION > 3.0-pre4. Remove `emulate -R zsh' 10# for all other values of $ZSH_VERSION > 2.6-beta2. For earlier versions 11# it still works if RC_EXPAND_PARAM is not set or when cdpath is empty. 12emulate -R zsh 13setopt localoptions 14local narg pref cdp 15 16read -nc narg 17read -Ac pref 18 19cdp=(. $cdpath) 20reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t) ) 21 22return 23# End of cdmatch. 24