Discussion:
Granular command completion
(too old to reply)
Roman Bigler (Privat)
2018-11-27 20:53:47 UTC
Permalink
Hello Bashers,

this might be a feature request, hope I’m posting to the correct place. If not, feel free to point me to the right place.

I’d like to customize bash’s command completion to _only_ include aliases.

Quoting the documentation, bash’s default completion tries in this order:

« The actual completion performed is application-specific. Bash attempts completion treating the text as a variable (if the text begins with ‘$’), username (if the text begins with ‘~’), hostname (if the text begins with ‘@’), or command (including aliases and functions) in turn. »

These seem to be customizable, with the exception of the command completion?

Reasons for my somewhat obscure requirement is the fact that I have to work under resource-constrained environments,
which at the same time employ a huge $PATH containing myriads of commands, which are abysmally slow to enumerate (not bash’s fault).

At the same time, I’m using bash to implement lightweight "shells” that, while being fully featured under the hood, (aim to) expose
a limited command subset in autocompletion for user convenience.

(I suppose the latter could in theory be achieved by employing readline directly, but it’s much more convenient configuring bash
accordingly).

I’ve managed to tell bash to complete only aliases upon an empty command line, but regular command completion still takes place
when parts on an alias are to be completed.

Cheers & thanks in advance,
roeme

P.S. If this indeed qualifies as a feature request…where to submit?
P.P.S. First post here, apologies if I inadvertently violated this list’s etiquette
Chet Ramey
2018-11-27 22:34:37 UTC
Permalink
Post by Roman Bigler (Privat)
Hello Bashers,
this might be a feature request, hope I’m posting to the correct place. If not, feel free to point me to the right place.
I’d like to customize bash’s command completion to _only_ include aliases.
You should be able to do this in bash-5.0 with the new `-I' (initial word)
option to `complete'. If you want to grab 5.0-beta2 from the bash-5.0-
testing branch or head from the devel branch you can try it out.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://tiswww.cwru.edu/~chet/
Dennis Williamson
2018-11-27 23:38:03 UTC
Permalink
Post by Roman Bigler (Privat)
Post by Roman Bigler (Privat)
Hello Bashers,
this might be a feature request, hope I’m posting to the correct place.
If not, feel free to point me to the right place.
Post by Roman Bigler (Privat)
I’d like to customize bash’s command completion to _only_ include
aliases.
You should be able to do this in bash-5.0 with the new `-I' (initial word)
option to `complete'. If you want to grab 5.0-beta2 from the bash-5.0-
testing branch or head from the devel branch you can try it out.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
With Bash 5 beta 2 this seems to do what you want:

complete -r
complete -I -a

That's upper case i.
Loading...