On Thu, Feb 24, 2011 at 8:46 PM, d...@ucore.info <d...@ucore.info> wrote:

> On Wed, Feb 23, 2011 at 5:06 AM, Clark J. Wang <dearv...@gmail.com> wrote:
> > I can give you an example here:
> >
> > bash# vi compgen-example.sh
> > _compgen_foo()
> > {
> >     local cmd=$1 cur=$2 pre=$3
> >
> >     if [[ $cur = % ]]; then
> >         COMPREPLY[0]='it-works'
> >     fi
> > }
> >
> > complete -F _compgen_foo foo
> > bash# source compgen-example.sh
> > bash# foo %<TAB>    <-- Press TAB here
> > bash# foo it-works    <-- `%' will be expanded like this
>
> Thanks.
>
> However this only registers for foo. What if I wanted to handle % for
> everything or even better ... only at places that expect the path? Any
> way to force bash to do that?
>
>
If you have only a few of commands you may define one compspec for each of
them (or let them share one single compspec). If you want the compspec work
for arbitrary commands you may consider using complete's -D option
(introduced in bash 4.1).

That's only my understanding and others may have better ideas. :)


>  Regards,
> Dawid
>
> --
> http://dpc.ucore.info
>



-- 
Clark J. Wang

Reply via email to