Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[zash-3.0.0] bug in cdmatch for dirs w/ embedded space?

I'm trying to get zsh to complete a directory that has an embedded
space, e.g., `foo bar' (personally I don't like them, but with
mac/win95 filenames it seems to be pretty common to come across).

I used the versions of compctl, cdmatch, and cdmatch2 distributed with
zsh-3.0.0, and invoked zsh with the -f switch. It fails because too
many backslashes get put in the completion, e.g.,

	% cd foo<TAB>
results in
	% cd foo\\\ bar/

Is there a more up to date cdmatch/compctl for this sort of thing? Or
is there a (non-default) that needs to be set?


Here's exactly what I did:

charney$ ~/bin/sunos-5.5/zsh-3.0.0 -f
charney% echo $ZSH_VERSION
charney% ls
foo bar
charney% if [[ -o AUTO_REMOVE_SLASH ]] then
then>     compctl -x 'p[2]' -Q -K cdmatch2 - 'S[/][~][./][../]' -g '*(-/)' + \
then>   -g '*(-/D)' - 'n[-1,/], s[]' -K cdmatch -q -S '/' -- cd pushd
then> else
else>     compctl -x 'p[2]' -Q -K cdmatch2 - 'S[/][~][./][../]' -g '*(-/)' + \
else>   -g '*(-/D)' - 'n[-1,/], s[]' -K cdmatch -S '/' -- cd pushd
else> fi
charney% fpath=(~/.zfunctions)
charney% autoload cdmatch
charney% autoload cdmatch2
charney% cd foo\\\ bar/    # typed cd foo<TAB> here
cd: no such file or directory: foo\ bar/
charney% cd foo\ bar
charney% pwd
/tmp/mdb/foo bar
charney% cat ~/.zfunctions/cdmatch
# 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.
# You do not have to include `.' in your cdpath.
# It works properly only if $ZSH_VERSION > 2.6-beta2. For erarlier versions
# it still works if RC_EXPAND_PARAM is not set or when cdpath is empty.
local narg pref cdp
read -nc narg
read -Ac pref
cdp=(. $cdpath)
reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t:gs/ /\\\\ /) )
# End of cdmatch.
charney% cat ~/.zfunctions/cdmatch2
# This function should be called from compctl to complete the
# second argument of cd and pushd.
local from
read -Ac from
eval "reply=( \${PWD:s@$from@$1*$2@}~$PWD(ND-/:) )"
reply=( "${${reply[@]#${PWD%%$from*}}%${PWD#*$from}}" )
[[ ${#reply[(r),-1]} != 0 ]] && reply[(r)]="''"


Messages sorted by: Reverse Date, Date, Thread, Author