Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Expand first before asking the question "Display all xxx possibilities?"

5 views
Skip to first unread message

積丹尼 Dan Jacobson

unread,
Aug 2, 2020, 6:55:45 PM8/2/20
to bug-...@gnu.org
Instead of

$ zz /jidanni_backups/da<TAB>
Display all 113 possibilities? (y or n) n

and then finally showing

$ zz /jidanni_backups/dan_home_bkp

how about doing the expansion first, so entering
$ zz /jidanni_backups/da<TAB> would then change into
$ zz /jidanni_backups/dan_home_bkp with below it the question
Display all 113 possibilities? (y or n)

Chet Ramey

unread,
Aug 5, 2020, 9:56:03 AM8/5/20
to 積丹尼 Dan Jacobson, bug-...@gnu.org, chet....@case.edu
Thanks for the suggestion.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ch...@case.edu http://tiswww.cwru.edu/~chet/

Chris Elvidge

unread,
Aug 5, 2020, 3:22:02 PM8/5/20
to bug-...@gnu.org
On 05/08/2020 02:55 pm, Chet Ramey wrote:
> On 8/2/20 6:55 PM, 積丹尼 Dan Jacobson wrote:
>> Instead of
>>
>> $ zz /jidanni_backups/da<TAB>
>> Display all 113 possibilities? (y or n) n
>>
>> and then finally showing
>>
>> $ zz /jidanni_backups/dan_home_bkp
>>
>> how about doing the expansion first, so entering
>> $ zz /jidanni_backups/da<TAB> would then change into
>> $ zz /jidanni_backups/dan_home_bkp with below it the question
>> Display all 113 possibilities? (y or n)

What happens if you have:
dan_home-bkp, dan_home_nobkp, dan-home-bkp, dan-nohome-bkp,
dan_nohome-bkp (etc.) in /jidanni_backups/?
Which do you choose for the first expansion?
>
> Thanks for the suggestion.
>


--
Chris Elvidge
England


Ilkka Virta

unread,
Aug 6, 2020, 8:13:44 AM8/6/20
to Chris Elvidge, bug-...@gnu.org
I think they meant the case where all the files matching the given
beginning have a longer prefix in common. The shell expands that prefix
to the command line after asking to show all possibilities.

$ rm *
$ touch dan_home_bkp{1..199}
$ ls -l da[TAB]
Display all 199 possibilities? (y or n) [n]
$ ls -l dan_home_bkp[cursor here]

So the shell has to fill in the common part anyway, and it might as well
do it first, without asking.

(Which just so happens to be what Zsh does...)


--
Ilkka Virta / itv...@iki.fi

Davide Brini

unread,
Aug 6, 2020, 8:27:26 AM8/6/20
to bug-...@gnu.org
On Thu, 6 Aug 2020 15:13:30 +0300, Ilkka Virta <itv...@iki.fi> wrote:

> I think they meant the case where all the files matching the given
> beginning have a longer prefix in common. The shell expands that prefix
> to the command line after asking to show all possibilities.
>
> $ rm *
> $ touch dan_home_bkp{1..199}
> $ ls -l da[TAB]
> Display all 199 possibilities? (y or n) [n]
> $ ls -l dan_home_bkp[cursor here]
>
> So the shell has to fill in the common part anyway, and it might as well
> do it first, without asking.

Don't know about the OP's environment, but it works out of the box for me,
and it always has, as far as I can remember:

$ touch dan_home_bkp{1..199}
$ ls da[TAB]
$ ls dan_home_bkp[TAB][TAB]
Display all 199 possibilities? (y or n)

$ bash --version
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)

--
D.

Chet Ramey

unread,
Aug 6, 2020, 9:00:03 AM8/6/20
to Ilkka Virta, Chris Elvidge, bug-...@gnu.org, chet....@case.edu
On 8/6/20 8:13 AM, Ilkka Virta wrote:
> On 5.8. 22:21, Chris Elvidge wrote:
>> On 05/08/2020 02:55 pm, Chet Ramey wrote:
>>> On 8/2/20 6:55 PM, 積丹尼 Dan Jacobson wrote:
>>>> how about doing the expansion first, so entering
>>>> $ zz /jidanni_backups/da<TAB> would then change into
>>  >> $ zz /jidanni_backups/dan_home_bkp with below it the question
>>  >> Display all 113 possibilities? (y or n)
>>
>> What happens if you have:
>> dan_home-bkp, dan_home_nobkp, dan-home-bkp, dan-nohome-bkp,
>> dan_nohome-bkp (etc.) in /jidanni_backups/?
>> Which do you choose for the first expansion?
>
> I think they meant the case where all the files matching the given
> beginning have a longer prefix in common. The shell expands that prefix to
> the command line after asking to show all possibilities.

Only if you set the "show-all-if-ambiguous" readline variable explicitly
asking for this behavior. Readline's default behavior is to complete up to
the longest common prefix, then, on the next completion attempt, to note
that there weren't any additional changes to the buffer and ask if the user
wants to see the alternatives. Dan wants a change in the behavior that
variable enables.

Ilkka Virta

unread,
Aug 6, 2020, 10:11:15 AM8/6/20
to chet....@case.edu, Chris Elvidge, bug-...@gnu.org
On 6.8. 15:59, Chet Ramey wrote:
> On 8/6/20 8:13 AM, Ilkka Virta wrote:
>> I think they meant the case where all the files matching the given
>> beginning have a longer prefix in common. The shell expands that prefix to
>> the command line after asking to show all possibilities.
>
> Only if you set the "show-all-if-ambiguous" readline variable explicitly
> asking for this behavior. Readline's default behavior is to complete up to
> the longest common prefix, then, on the next completion attempt, to note
> that there weren't any additional changes to the buffer and ask if the user
> wants to see the alternatives. Dan wants a change in the behavior that
> variable enables.

Right, sorry.

I do have it set because otherwise there's a step where tab-completion
only produces a beep, and doesn't do anything useful. I didn't realize
causes partial completion to be skipped too.

Chet Ramey

unread,
Aug 7, 2020, 11:19:40 AM8/7/20
to Ilkka Virta, Chris Elvidge, bug-...@gnu.org, chet....@case.edu
It's not `skipped'. The partial match gets inserted before you go back to
line editing, when you can actually do something with it. There's no real
good HCI reason to insert it first only to have it scroll off the screen
as readline displays the possible matches, then insert it again before
going on. And say you decline to see the possible matches -- the partial
match gets inserted before you go back to editing anyway.
0 new messages