[Bash-completion-devel] Fwd: Bash completion ideas (was 'bash development list')

Mike Kelly pioto at exherbo.org
Fri Jan 16 22:38:29 UTC 2009


On Fri, Jan 16, 2009 at 11:14:47PM +0100, nadim khemir wrote:

> 1/ Why aren't all the arguments to the command passed to the completion 
> script? This is purely and simply a lobotomization of the completion 
> mechanism.

All the arguments typed thusfar should be available in the COMP_WORDS
array. For example, to get the previously typed argument, as well as the
argument currently being typed:

    prev=${COMP_WORDS[COMP_CWORD-1]}
    cur=${COMP_WORDS[COMP_CWORD]}
    
COMP_CWORDS is a zero-indexed array. COMP_CWORD is the index of the
word that is currently being completed.

-- 
Mike Kelly



More information about the Bash-completion-devel mailing list