Many developers switching from Bash to Zsh (especially through Oh My Zsh) notice a fundamental difference in tab completion behavior:
- Bash: Shows all possible completions without automatic selection
- Zsh: Automatically selects the first completion and cycles through options
This becomes particularly noticeable when working with commands like git
or file paths where partial matches are common.
Zsh's default behavior stems from its menu-select
completion style. To make it behave more like Bash, we need to modify the completion system configuration.
Add these lines to your ~/.zshrc
file:
# Disable menu selection
zstyle ':completion:*' menu no
# Make completion behave more like bash
autoload -Uz compinit
compinit
zstyle ':completion:*' list-prompt ''
zstyle ':completion:*' select-prompt ''
setopt noautomenu
setopt nomenucomplete
For developers who want partial Bash-like behavior with some Zsh enhancements:
# Hybrid approach
zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 2
zstyle ':completion:*' list-colors ''
After making changes:
- Run
source ~/.zshrc
- Test with a command that has multiple completions (e.g.,
git che<tab>
) - Verify the behavior matches your expectations
If you're using Oh My Zsh, these configurations should be placed after the line that sources Oh My Zsh in your .zshrc
:
# Example placement
source $ZSH/oh-my-zsh.sh
# Your customizations go here
If completion stops working entirely:
rm ~/.zcompdump*
exec zsh
This will regenerate your completion cache while preserving your new settings.
As a former bash user switching to zsh (particularly through oh-my-zsh), you'll notice fundamental differences in completion behavior:
- Bash: Shows all possible completions immediately, only filling common prefixes
- Zsh: Automatically selects the first completion, requiring tab-cycling
Zsh's advanced completion system (compinit
) offers more flexibility than bash's but comes with different defaults. The key components are:
autoload -Uz compinit
compinit
Add these settings to your ~/.zshrc
:
# Disable menu selection and auto-first
zstyle ':completion:*' menu no
zstyle ':completion:*' list-prompt ''
zstyle ':completion:*' select-prompt ''
# Show all completions immediately
setopt no_auto_menu
setopt no_menu_complete
setopt no_auto_list
# Only insert common prefix (like bash)
setopt no_complete_aliases
For power users who want partial bash-like behavior while keeping some zsh features:
# Hybrid approach (lists completions but keeps zsh's navigation)
zstyle ':completion:*' menu select=1
zstyle ':completion:*' list-colors ''
zstyle ':completion:*:*:*:*:*' menu select
If completions stop working after these changes:
- Run
rm ~/.zcompdump*
- Restart your shell
- Check for conflicts in your oh-my-zsh plugins
With bash-style settings:
$ cd /u/l/b<TAB>
usr/ local/ lib/ lib64/
Versus default zsh:
$ cd /u/l/b<TAB>
# Automatically completes to /usr/local/bin
# Requires additional tabs to see other options