Matthew Woehlke wrote:
Because "for some reason, non-trivial completions never seem to want to
work for me"?
Sigh. Ok, after trying for entirely too long, this seems to be working:
completeme() {
local i=0
while read l; do
COMPREPLY[$((++i))]="$l"
done < <(
cd /some/prefix
w="${COMP_WORDS[1]}"
if [ -n "$w" ]
then compgen -d "$w"
else compgen -d
fi
)
}
complete -F completeme cs
...and yet, seems entirely too difficult.
Maybe something like this?
foo()
{
local -a a
PREFIX=/usr/local
builtin cd $PREFIX || {
COMPREPLY=()
return 1
}
a=( $(compgen -d "$2") )
COMPREPLY=( "[EMAIL PROTECTED]/}" )
builtin cd $OLDPWD
}
The difficulty is getting a trailing `/' -- readline won't add it, since
the completions are in a different directory.
Why doesn't 'complete -C' work?
Programmable completion invokes the command specified with -C with three
arguments:
$1 = command name
$2 = word to be completed (possibly null)
$3 = previous word
It's really designed to work with external commands or shell functions
that understand arguments, not command lists. There's no other way for
an external command to get the word to be completed.
Why does 'compgen -d ""' produce no
output? Shouldn't it produce the same output as 'compgen -d'?
Ummm...it does for me.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, ITS, CWRU [EMAIL PROTECTED] http://cnswww.cns.cwru.edu/~chet/