In zsh and in bash, if I type ls c<TAB> it displays every filename starting with c. If instead I type ls c*<TAB>, bash behaves the same way, but zsh replaces the c* with the list of every file starting with c. Is there any way to make zsh behave like bash does?


From man zshoptions:


When the current word has a glob pattern, do not insert all the words resulting from the expansion but generate matches as for completion and cycle through them like MENU_COMPLETE. The matches are generated as if a ‘*’ was added to the end of the word, or inserted at the cursor when COMPLETE_IN_WORD is set. This actually uses pattern matching, not globbing, so it works not only for files but for any completion, such as options, user names, etc.

Note that when the pattern matcher is used, matching control (for example, case-insensitive or anchored matching) cannot be used. This limitation only applies when the current word contains a pattern; simply turning on the GLOB_COMPLETE option does not have this effect.

  • That just replaces the pattern with the first match rather than all the matches. I want to only list the matches. – m42a May 6 '12 at 6:47
  • If you keep hitting tab, it should cycle through the matches. If it's not also displaying the list of matches, you may have to mess with your zsh completion options. – mkarasek May 6 '12 at 23:47
  • I don't want to cycle through options though, I only want to list them. – m42a May 7 '12 at 8:11
  • @m42a: Did you ever figure out how to do that? – user193100 May 6 '13 at 0:11
  • @m42a you may want to set menu_complete and auto_list. – PythonNut Aug 26 '14 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.