Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [zash-3.0.0] bug in cdmatch for dirs w/ embedded space?
- X-seq: zsh-workers 2138
- From: Peter Stephenson <pws@xxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Zsh hackers list)
- Subject: Re: [zash-3.0.0] bug in cdmatch for dirs w/ embedded space?
- Date: Fri, 13 Sep 1996 09:50:49 +0200
- In-reply-to: ""alain (a.) caron""'s message of "Thu, 12 Sep 1996 15:38:00 MET." <"9653 Thu Sep 12 18:01:31 1996"@bnr.ca>
"alain (a.) caron" wrote:
> >reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t:gs/ /\\\\ /) )
>
> replace this last line by:
>
> reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t) )
Yes, this works. However, this version of cdmatch has the (for me at
least) critical limitation that it doesn't handle subdirectories, just
the first one below the directory in $cdpath. I've gone back to a
previous version of cdmatch and applied the same treatment, which
works there too, so the following is what I'm using at the moment.
Sorry, I can't remember who wrote this one originally.
The compctl instructions at the top of the other one still apply,
though I find it simpler to see if ordinary completion will find a
directory, and only then use cdmatch:
compctl -g '*(-/)' + -K cdmatch -S / -q cd pushd
###############################################################################
# cdmatch - directory matching for cd
#
# Save in your functions directory and autoload, then do
# compctl -K cdmatch -S / -q + -g '*(D-/)' cd pushd
#
# Completes directories using cdpath (as cd does). . is automatically
# included, because cd works that way.
#
# If an absolute path is being specified, or cdpath is blank, the completion is
# left up to the shell. This results in such completions having a different
# look from those done by cdmatch itself. Hopefully a future version of zsh
# will rectify this in some way.
local notonlydot npos args pref dir d
reply=()
# check for cdpath empty or only containing .
for dir in $cdpath; do [[ $dir != . ]] && notonlydot=1; done
if [[ $notonlydot != 1 ]]; then return; fi
# get word on which completion is requested
read -nc npos
read -Ac args
# check for absolute path - watch out for erroneous ~ expansion
pref=x$args[$npos]
if [[ $pref[2] = [/\~] ]]; then return; fi
# relative path - use cdpath
pref=$args[$npos]
for dir in . $cdpath; do
for d in $dir/$pref*(ND-/:s,$dir/,,); do
reply=( $reply ${d%%/#} )
done
done
return
###############################################################################
--
Peter Stephenson <pws@xxxxxx> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author