Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show-all-if-ambiguous vs show-all-if-unmodified?

I couldn't find a clear explanation of the difference between the Readline options show-all-if-ambiguous and show-all-if-unmodified, and whether they affected different things or were mutually exclusive. The official documentation is sparse on the subject.

like image 542
Kvass Avatar asked Feb 12 '17 19:02

Kvass


Video Answer


2 Answers

By default, readline will not print any possible completions if there is more than one possible completion. Additionally, if all possible completions share a common prefix, that common prefix is inserted.

The two options discussed change readline's behavior:

  • show-all-if-ambiguous will cause readline to print possible completions after the first Tab press, even if there is more than one.
  • show-all-if-unmodified will do the same, except for the case when all completions share a common prefix.

An example:

Let's say we have two possible completion matches, and they share a common prefix. For example, in an empty directory, run:

touch ___1 ___2

Now, type :SpaceTab

If we have show-all-if-ambiguous turned on, the screen will look like:

$ :
___1  ___2
$ : ___

But if we have only show-all-if-unmodified turned on, the screen will look like:

$ : ___

Note that this point, pressing Tab will trigger the display of possible completions in either case. However, were we to have neither of the above options turned on, nothing would happen and we would have to press Tab once more to get the listing.

like image 35
Grisha Levit Avatar answered Oct 29 '22 19:10

Grisha Levit


Using the descriptions from the man page

show-all-if-unmodified

This alters the default behavior of the completion functions in a fashion similar to show-all-if-ambiguous. If set to ‘on’, words which have more than one possible completion without any possible partial completion (the possible completions don’t share a common prefix) cause the matches to be listed immediately instead of ringing the bell. The default value is ‘off’.

This means that if any partial completions can be made then they will be filled in and all of the completions will not be shown.
If there is no partial completion to be made then all completions are shown.

show-all-if-ambiguous

This alters the default behavior of the completion functions. If set to ‘on’, words which have more than one possible completion cause the matches to be listed immediately instead of ringing the bell. The default value is ‘off’.

This means that the word will be partially completed up to the point where there is ambiguity AND will print all completions in one step.


Example

Say we have a files abcd.txt and abce.txt

Using
show-all-if-unmodified

typing

$ls a<tab>

will show

$ls abc

and pressing tab again (as there are no partial completions) would result in

$ls abc
abcd.txt abce.txt
$ls abc

Using
show-all-if-ambiguous

typing

ls a<tab>

will show

$ls a
abcd.txt abce.txt
$ls abc

So performs both actions in one step.

Also note that show-all-if-ambiguous overrides show-all-if-unmodified so if both are set to on then the behaviour will be that of the former.

like image 182
123 Avatar answered Oct 29 '22 20:10

123