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

Re: bash completion and spaces



On Thu 22 Apr 2021 at 15:28:36 (+0700), Victor Sudakov wrote:
> 
> I have an example app which can be run only as "app3 -h test1 -s foo" or
> "app3 -h test2 -s bar". So I decided to provide it with a small manual
> completion for convenience.
> 
> [vas@test2 ~]$ ./list.sh 
> -h test1 -s foo
> -h test2 -s bar
> [vas@test2 ~]$ complete -C ./list.sh app3
> [vas@test2 ~]$
> 
> The result however is discouraging, the completion mechanism won't add
> whole lines of parameters, it's trying to split on spaces (here I press
> <TAB> several times:
> 
> [vas@test2 ~]$ app3 -h -h -h test
> 
> Can you please give a hint how to make it complete "app3" with either
> "-h test1 -s foo" or "-h test2 -s bar" as a whole?
> 
> I would not like to make all this too complicated, write complex
> completion funcions if possible. A static (-W) completion would be even
> better.

Perhaps:

alias app3a='app3 -h test1 -s foo'
alias app3b='app3 -h test2 -s bar'

Cheers,
David.


Reply to: