[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] [completion] Is it possible to auto complete one word in
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] [completion] Is it possible to auto complete one word into multiple ones? |
Date: |
Thu, 30 Jul 2015 10:10:46 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 |
On 7/29/15 11:08 PM, Clark Wang wrote:
> On Wed, Jul 29, 2015 at 10:19 PM, Chet Ramey <address@hidden
> <mailto: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.
Only if you ask for it. If you specify you're completing filenames, you
get filename-like quoting. You can also use `compopt -o noquote' to
turn it off for this case if your compspec enables it by default.
Chet
--
``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/