How to get case-insensitive completions without Ohmyzsh?
Asked Answered
B

2

5

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?

Brew answered 8/10, 2021 at 15:7 Comment(3)
This answer looks like it might work: https://mcmap.net/q/293624/-have-zsh-return-case-insensitive-auto-complete-matches-but-prefer-exact-matchesGrouse
That worked, I had not seen this part. I cannot mark your comment as an answer, but it is. So I will change the title to [solved]?? I don't know how to proceed.Brew
Please do not put “[SOLVED]” in the title. Either close your question or add your own answer and accept it.Hypothalamus
B
10

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
Brew answered 11/10, 2021 at 22:42 Comment(0)
J
0

The accepted answer threw the error .zshrc:4: command not found: l:|=* r:|=* on iterm. So I changed it to this:

zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=**'
Jurel answered 9/10, 2024 at 17:21 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Torpedo

© 2022 - 2025 — McMap. All rights reserved.