shellzshoh-my-zsh

How to get case-insensitive completions without Ohmyzsh?


I'm using OHMYZSH but I'm thinking about building a minimal configuration to Zsh.

So here's the problem. Ohmyzsh has special behaviour for completion. For example: if I'm in my Home Directory and type cd mus and hit a TAB it will expand to cd Music, even I'm typing the sentence with small letters.

I've founded this:

Have zsh return case-insensitive auto-complete matches, but prefer exact matches

Which is my problem but on the contrary. I want to get case insensitive without install OHMYZSH.

Looking at the OHMYZSH structure, I've found this:

.
├── ./cache
├── ./CODE_OF_CONDUCT.md
├── ./CONTRIBUTING.md
├── ./custom
├── **./lib**
├── ./LICENSE.txt
├── ./log
├── ./oh-my-zsh.sh
├── ./plugins
├── ./README.md
├── ./templates
├── ./themes
└── ./tools

8 directories, 5 files

Inside the lib folder, there are some config files.

lib
├── bzr.zsh
├── clipboard.zsh
├── cli.zsh
├── compfix.zsh
├── completion.zsh
├── correction.zsh
├── diagnostics.zsh
├── directories.zsh
├── functions.zsh
├── git.zsh
├── grep.zsh
├── history.zsh
├── key-bindings.zsh
├── misc.zsh
├── nvm.zsh
├── prompt_info_functions.zsh
├── spectrum.zsh
├── termsupport.zsh
└── theme-and-appearance.zsh

0 directories, 19 files

I've already tried to source the completion.zsh using Zinit (plugin manager for ZSH which enables load some OHMYZSH stuff) without success. I don't know what is the correct file for the behaviour I want.

This is my config:

#exports
export EDITOR=nvim
export VISUAL=code
export SUDO_EDITOR=nvim

# Theme
ZSH_THEME="spaceship"

#PLUGINS
#==============================================================
source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

zinit light zdharma/fast-syntax-highlighting
zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-completions
zinit light agkozak/zsh-z

#THIS LINE IS MY ATTEMPT TO load OHMYZSH FILES
zinit snippet OMZL::completion.zsh
#==============================================================
### End of Zinit's installer chunk

What's the correct file to load? Or is there another way to get case insensitive completions?


Solution

  • After reading some comments I found a solution. Add these two lines to the Zsh config file:

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