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: Chet Ramey
Subject: Re: [Help-bash] How to keep only files match the prefix when do command completion?
Date: Wed, 14 Dec 2011 15:04:34 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 12/14/11 2:12 PM, Peng Yu wrote:
>> _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).

After these matches have been generated, any shell function or command
specified with the @option{-F} and @option{-C} options is invoked.
When the command or function is invoked, the @env{COMP_LINE},
@env{COMP_POINT}, @env{COMP_KEY}, and @env{COMP_TYPE} variables are
assigned values as described above (@pxref{Bash Variables}).
If a shell function is being invoked, the @env{COMP_WORDS} and
@env{COMP_CWORD} variables are also set.
When the function or command is invoked, the first argument is the
name of the command whose arguments are being completed, the
second argument is the word being completed, and the third argument
is the word preceding the word being completed on the current command line.
No filtering of the generated completions against the word being completed
is performed; the function or command has complete freedom in generating
the matches.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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