Often I would like to rapidly build a path in zsh through completion. The problem is that, when I have completed a segment, there seems to be no good way to begin completion of the next segment. For example, suppose I have the following structure:

|- apple
|- apricot
|--- banana
|--- blueberry

I want to complete the path /apple/blueberry:

$ cd /ap  # <TAB>
$ cd /apple/  # <TAB>
$ cd /apricot/  # <TAB>
$ cd /apple/  # <TAB>
$ cd /apricot/ # ...

The issue is that, when I try to complete on /apple/, it cycles to the next match rather than starting a "fresh" completion, as would occur if I did this:

$ cd /apple/ # <TAB>
$ cd /apple/banana # <TAB>
$ cd /apple/blueberry

I understand that I could type the first character "b" and start a new completion from this, but I don't want to have to do that-- I want to list/cycle through all child files/directories. How can I start a fresh completion after getting a successful intermediate completion?

1 Answer 1


Type a slash. When zsh completes a directory name, it adds a “tentative” trailing /. By default, the tentative character is in bold. If you then type a slash or a space, that tentative slash is removed. So if you type a slash immediately after completing the directory name, you turn the tentative slash into a “normal” slash. Since you've typed something, the completion of the directory /apple is over, so Tab will complete entries inside /apple/.

  • Can't believe I missed something so simple, thanks for the answer. Jul 9, 2020 at 19:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .