Re: [Help-bash] [completion] Is it possible to auto complete one word in
From:
Clark Wang
Subject:
Re: [Help-bash] [completion] Is it possible to auto complete one word into multiple ones?
Date:
Thu, 30 Jul 2015 11:08:45 +0800
On Wed, Jul 29, 2015 at 10:19 PM, Chet Ramey <address@hidden> wrote:
> On 7/27/15 4:24 AM, Clark Wang wrote:
> > For example, the foo command has a ``--select all'' option but has no
> > ``-a'' option. I want to define a compspec for foo so when I input ``foo
> > -a'' and press <TAB> it'll replace ``-a'' with ``--select all''.
>
> Make your completion function set COMPREPLY[0]='--select all' when
> ${COMP_WORDS[$COMP_CWORD]} == '-a' (or $2 == '-a'). Make it a special
> case if you have to.
>
Cool it's so easy. I had thought Bash would smartly expand it to
``--select\ all'' so I even did not try that. Thanks.
-clark
>
> --
> ``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/
>