davidson wrote: > On Sat, 24 Apr 2021 Victor Sudakov wrote: > > David Wright 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? > > Almost entirely idle curiosity: the arguments test1/test2 and foo/bar > which your app3 requires, are they arbitrary strings? Or are they > instead paths to files, or perhaps one of the other 20-odd categories > recognised by the -A option for bash builtin "complete"?
"-h" are hosts to connect to, so I could probably get them completed as "-A hostname", but the remaining arguments are arbitrary strings. > > > > > > > I would not like to make all this too complicated, write complex > > > > > > completion funcions if possible. > > In the case you describe, you might find the behaviour of readline > function "menu-complete" slightly more helpful than the readline > function "complete" presently mapped to TAB (given that you find the > behaviour of "complete" completely unhelpful, naturally enough). > > See readline(3) for some documentation. > > You could, say, map Shift-TAB to "menu-complete" in ~/.inputrc > > (In emacs to get Shift-TAB to produce a literal Shift-TAB, you'll need > to hit Ctrl-q first.) > > I make this suggestion as a partial workaround/improvement to present > situation. I doubt you'll find it an ideal solution. I'm surprised to find out that it has become so complicated. [dd] > > > > BTW on my current Debian system I don't see the space character in > > $COMP_WORDBREAKS. > > If you have xxd installed, what does xxd show you? I actually looked with `hd` and expected to see 0x20 there, but somehow see none of it: $ echo $COMP_WORDBREAKS | hd 00000000 22 27 40 3e 3c 3d 3b 7c 26 28 3a 0a |"'@><=;|&(:.| 0000000c -- Victor Sudakov VAS4-RIPE http://vas.tomsk.ru/ 2:5005/49@fidonet
signature.asc
Description: PGP signature