Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I get zsh tab completion to cat **/foo<TAB> to match and complete the first file matching foo* in any subdirectory under the current directory?

For example, do this while inside a fresh test directory: (again, this is zsh)

% mkdir aaa bbb ccc
% touch aaa/foo bbb/foo ccc/foo
% cat **/f<TAB>

What I want when I hit <TAB> on that last line is for my screen to end up looking like this:

% cat aaa/foo_                 # filled in the first match; "_" is the cursor
aaa/foo  bbb/foo  ccc/foo      # and here is the list of all matches

I tried setopt GLOB_COMPLETE, but that didn't do what I wanted.

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.