home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC-Online 1996 May
/
PCOnline_05_1996.bin
/
linux
/
source
/
ap
/
zsh
/
zsh-2.4
/
zsh-2
/
zsh-2.4.306
/
func
/
cdmatch
< prev
next >
Wrap
Text File
|
1993-09-06
|
787b
|
36 lines
# Start of cdmatch.
# Save in your functions directory and autoload, then do
# compctl -K cdmatch -S '/' cd pushd
# or if you prefer
# compctl -K cdmatch -S '/' -x 'S[/][~]' -g '*(-/)' -- cd pushd
# (to use ordinary globbing for absolute paths).
#
# Completes directories for cd, pushd, ... anything which knows about cdpath.
# Note that . is NOT automatically included. It's up to you to put it in
# cdpath somewhere.
local dir nword args pref ngtrue
[[ -o nullglob ]] && ngtrue=1
setopt nullglob
read -nc nword
read -Ac args
pref=$args[$nword]
if [[ $pref[1] = [/\~] ]]; then
eval "reply=($pref*(-/))"
else
reply=()
for dir in $cdpath
do
eval "reply=(\$reply $dir/$pref*(-/:s,$dir/,,))"
done
fi
[[ $ngtrue = 1 ]] || unsetopt nullglob
return
# End of cdmatch.