4

How can I achieve fish-like path completion in zsh?

Suppose I have a file named abce-fg, in fish shell when I type:

$ ls abef<Press Tab here>

fish will complete abce-fg for me.

Notice that abef is a subsequence of abce-fg.

How do I achieve this in zsh?

1 Answer 1

4

Add this to your .zshrc file:

autoload -Uz compinit && compinit
zstyle ':completion:*' matcher-list 'r:|?=**'

Alternatively, install the zsh-autocomplete plugin for fuzzy matching, spelling correction, real-time autocompletion and many more completion features.

live file search

live history search

1
  • Thanks for you answer @Marlon . But I still have a small problem. When preceded with a directory, instead of listing all candidates, zsh will simply complete the common prefix. Say I have abcde and bcde in /tmp/, when I type /tmp/cde<Tab> zsh will complete the common prefix, which is a empty string in the case of abcde and bcde. Is it possible to list the candidates when preceded with directory? Commented Apr 29, 2021 at 10:53

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.