help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] How to keep only files match the prefix when do command


From: Peng Yu
Subject: Re: [Help-bash] How to keep only files match the prefix when do command completion?
Date: Wed, 14 Dec 2011 13:12:22 -0600

> _unison_command() {
>   local array=(~/.unison/"$2"*.prf)
>   if [[ -e ${array[0]} ]]; then
>     COMPREPLY=( "address@hidden/#*\/}" )
>   fi
> }

Hi Geir,

Thanks! Only by you example, I understand how to use 'complete -F'.

I have to say the current wording of the manual is completely
unhelpful. I think that the section 8.6 and 8.7 should be written and
add more pedagogical examples so that users can understand what it
does. As of now, in particular for complete -F, it doesn't cover what
the function should do and what arguments should be passed to the
function (unless this is written in some obscure place, but it also
means that the manual should be rewritten).

I guess from the context, $2 is the prefix. But what is $1, and $3, $4, etc.?


-F function
The shell function function is executed in the current shell environment.
When it finishes, the possible completions are retrieved from
the value of the COMPREPLY array variable.

-- 
Regards,
Peng



reply via email to

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