shellautocompletezsh

Zsh tab-completion not working


Although I've used Oh-My-Zsh in the past, I decided this time around (i.e. setting up a new computer) I'd try to avoid installing it to keep things a bit leaner. Right now I'm trying to cherry-pick Oh-My-Zsh's insensitive tab-completion feature. Digging around its source repo, I found the following line:

zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'

I'm fairly confident this is the line Oh-My-Zsh executes to do what I want, so I tried adding it to my .zshrc. Restarted my terminal. Typed cd desk, then hit [tab]. No dice -- I didn't get cd Desktop/.

Here's the entire .zshrc for reference:

# pure shell theme
autoload -U promptinit; promptinit
prompt pure

# completion definitions
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
fpath=(/usr/local/share/zsh-completions $fpath)

# syntax highlighting (must be last line)
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

What am I doing wrong?


Solution

  • Just had to autoload and run compinit.

    Here's the new .zshrc:

    autoload -U compinit promptinit
    
    promptinit
    prompt pure
    
    compinit
    zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
    fpath=(/usr/local/share/zsh-completions $fpath)
    
    source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh