Discussion:
[Help-bash] $<space><tab> completes to files rather than commands
Michal Pesa
2018-07-16 14:43:40 UTC
Permalink
Hello.

Please take a look at the following scenarios where "$" is the beginning
of the prompt:

1) $<tab> # complete -E will be used

2) $p<tab> # commands beginning with "p" will be completed

3) $<space>p<tab> # commands beginning with "p" will be completed again

4) $<space><tab> # all files in the current dir (for some reason) will
be completed

Why doesn't 4) complete to all possible commands instead of all files
since it's the first word on the line? Is the completion of the first
word configurable at all (not counting complete -E)? Let's say I wanted
$p<tab> to complete only to a subset of commands I choose.


Thank you for your time.
Chet Ramey
2018-07-16 18:15:05 UTC
Permalink
Post by Michal Pesa
Hello.
Please take a look at the following scenarios where "$" is the beginning of
1) $<tab> # complete -E will be used
2) $p<tab> # commands beginning with "p" will be completed
3) $<space>p<tab> # commands beginning with "p" will be completed again
4) $<space><tab> # all files in the current dir (for some reason) will be
completed
Why doesn't 4) complete to all possible commands instead of all files since
it's the first word on the line?
It's not an empty line -- point and end are not at column 0 -- so the
compspec supplied with -E won't be used. Bash-4.4 has a logic flaw that
causes it to assume that filename completion is desired when programmable
completion is active and the command name is empty. This is fixed in
bash-5.0-alpha.
Post by Michal Pesa
Is the completion of the first word
configurable at all (not counting complete -E)? Let's say I wanted $p<tab>
to complete only to a subset of commands I choose.
Recent devel branch pushes (not in bash-5.0-alpha) have a `complete -I'
option to install a compspec that will be used on the initial word. Read
the discussion starting at

http://lists.gnu.org/archive/html/bug-bash/2018-06/msg00003.html

for more information.
--
``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/
Loading...