[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: completing dir names for a certain path?

From: Chet Ramey
Subject: Re: completing dir names for a certain path?
Date: Fri, 22 Aug 2008 21:38:40 -0400
User-agent: Thunderbird (Macintosh/20080707)

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
  done < <(
    cd /some/prefix
    if [ -n "$w" ]
      then compgen -d "$w"
      else compgen -d
complete -F completeme cs

...and yet, seems entirely too difficult.

Maybe something like this?

        local -a a

        builtin cd $PREFIX || {
                return 1
        a=( $(compgen -d "$2") )

        COMPREPLY=( "address@hidden/}" )

        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

        $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.

``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]