While trying to configure the programmable completion, I came across a behavior I don't understand.
Given those three completion scenarios, this is the way I understand them:
$<TAB><TAB>
Beginning of the line --> use complete -E
--> if it doesn't exist, use complete -D
--> if it doesn't exist, use the default Bash completion --> there are no words on the line --> use command completion.
$com<TAB><TAB>
Trying to complete first word --> use command completion.
$command argu<TAB><TAB>
There is at least one word on the line --> trying to complete an argument --> use complete
for the given command --> if it doesn't exist, use complete -D
--> if it doesn't exist, use the default Bash completion --> there is already at least one word on the line so don't use command completion --> doesn't start with $
, ~
or @
so perform filename completion.
My question is why is the filename completion performed instead of command completion in this scenario even though there are no words on the line yet:
$<SPACE><TAB><TAB>
It's even more confusing since the command completion below is performed as expected:
$<SPACE>com<TAB><TAB>
I most likely misunderstood the manual and I would be most grateful for any explanation.
NOTE:
$
denotes the prompt, not a literal dollar sign.
$
literal (a part of your command that you entered by hand), or are you just using it to represent the command line prompt? For me (using bash-completion), a literal$<tab><tab>
shows the list of variables I could complete.$<space><tab><tab>
assumes$
is a command without any known parameters and therefore completes with file names by default. – Greatniececomplete -p
– Aesculapius