0

In zsh with oh-my-zsh, I like how I can, within this directory for instance:

mydir/
  app.component.html
  app.component.ts
  app.module.ts
  app-routing.module.ts

type ./html<tab> and have it automatically expanded as ./app.component.html, even though the filename doesn't actually start with html, but it is a part that is characteristic.

Also, I can ./rout<tab> to get ./app-routing.module.ts with a middle clue.

If I use something ambiguous, like ./ts<tab>, the experience is a bit weirder, since

  • 1. it first expands to the longest common part ./|.ts (where | represents my cursor's position).
  • 2. on a second press to <tab> (why not the first?), I get a list of options displayed below:
$ ./|.ts
app.component.ts       app.module.ts
  • 3. on a third press to <tab> (why a third?), the first item of the list get selected.
  • 4. then, after one last <tab>, I finally get my expansion to ./app.module.ts.

I understand that zsh needs more input since my initial clue was ambiguous, but I'm sure that 2 <tabs> would have been saved in the above process if the first <tab> directly resulted in 3. instead of 1. Is there anything I can configure about this?

Finally, if I use a non-terminal ambiguous clue, things start feeling clumsy. For instance ./mod<tab> results in

  • 1. ./|d.module.ts (not sure where this d comes from).

  • 2. a second <tab> just shifts the cursor to the end: ./d.module.ts|.

  • +∞. pressing <tab> does not change anything from this point on, or propose a list of options like it did before. So I end up scrolling back and fixing the filename myself.

I would have expected a list of options to be offered in only one <tab>, like in the previous case.

Is this expected behaviour?
Have I not understood quite well the way autocompletion is supposed to work?
Is this something I can configure, and how?

4
  • iago-lito: the Stack Exchange system has unfortunately run into some kind of bug (possibly meta.stackexchange.com/a/345859/307535) regarding your question being closed as a duplicate of another one. For the time being, I'd like to reopen your question and ask if you could post a comment pointing to the Q/A that you think this is a duplicate of. Thank you! – Jeff Schaller Apr 4 '20 at 12:52
  • @JeffSchaller Haha, I have been wondering whether it would cause a bug to self-close-as-duplicate, because it felt weird doing so X) Here is the post where I have finally found my answer: unix.stackexchange.com/q/12288/87656. Is it considered bad practise? Should I have closed instead? – iago-lito 'considering leaving Apr 4 '20 at 13:00
  • 1
    Finding a duplicate and self-closing is perfectly fine! I assume we just encountered a software bug of some sort. I'll try closing it and see what happens. – Jeff Schaller Apr 4 '20 at 14:27
  • 1
    Update: it seems the glitch has been fixed – Jeff Schaller Apr 6 '20 at 1:57