Setup

Terminal completion

Not checked yet

In Terminal, pressing Tab finishes the name of a file or folder for you. Out of the box it is strict: type doc and press Tab, and it will not find Documents, because of the capital D.

This block makes completion ignore case, and also lets it match after a dot, dash or underscore and in the middle of a name.

grep -q "## ZSH_COMPLETION_UNIVERSAL_START" ~/.zshrc 2>/dev/null || printf "%s\n" \
"## ZSH_COMPLETION_UNIVERSAL_START" \
"autoload -Uz compinit" \
"compinit" \
"zstyle ':completion:*' matcher-list \\" \
"  'm:{a-zA-Z}={A-Za-z}' \\" \
"  'r:|[._-]=* r:|=*' \\" \
"  'l:|=* r:|=*'" \
"## ZSH_COMPLETION_UNIVERSAL_END" \
>> ~/.zshrc; rm -f ~/.zcompdump*; source ~/.zshrc

Paste the whole block into Terminal and press Return.

What it does

It adds a few lines to ~/.zshrc, the file your shell reads every time a Terminal window opens. The first line checks whether the block is already there, so running it twice does no harm. The last line clears the completion cache and reloads the file, so the change works in the window you are in.

To remove it, open ~/.zshrc in a text editor and delete everything from the START line to the END line.