zsh completion : suggestion of multiples directory and how to choose one without knowing the content of this directory

Viewed 638

I have a simple issue with zsh. Sometimes, I am in a directory with multiples sub-directories.

So, when I do a $ ls[TAB] or $cd[TAB], I list all these sub-directories.

But how to accept one of the suggestions for sub-directories? Is there a short cut or a key to choose a directory to go deeper in this directory.

I must precise that I don't know systematically the content of these subdirectories, so I can't often choose a subdirectory in which the first letter of filename could allow me to choose automatically the sub-directory to explore.

I was looking for a solution on the web but documentation about zsh completion is pretty big.

2 Answers

The only way I know is: double click your target + cmd c + cmd v and then press Enter.

Edit: simplest solution to accomplish the desired effect: press [/] key to 'accept' the current suggested directory ; then press again [tab] key to show suggestions of its subdirectories

Old suggested solution:

Install https://ohmyz.sh/

Then pressing the [tab] key displays a list and the first item is highlighted. Hit the [tab] key again to choose the desired item and hit the [enter] key to write it in the command line interface, without actually executing the command, only as if you have just typed it in.

Then you can continue hitting the [tab] key to select another subdirectory, and so on.

It also works on any autocompletable, not only dirs.

Related