bug-bash
[Top][All Lists]
Advanced

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

Re: Question. Autocomplete paths starting with %.


From: Clark J. Wang
Subject: Re: Question. Autocomplete paths starting with %.
Date: Thu, 24 Feb 2011 22:49:46 +0800

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

> On Wed, Feb 23, 2011 at 5:06 AM, Clark J. Wang <dearvoid@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

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