If you use Zsh, you can supercharge your command line by enabling autocomplete for all your tools like Git, npm, and Docker. This allows Zsh to suggest and complete commands, flags, and arguments as you type, saving time and preventing typos.
How to enable it
The process is remarkably simple. You only need to add two lines to your Zsh configuration file.
Open your .zshrc
file in any text editor:
open ~/.zshrc
Add the following lines to the end of the file:
autoload -Uz compinitcompinit
Save the file, then restart your terminal or apply the changes by running:
source ~/.zshrc
How it works
These two commands activate Zsh’s powerful completion system. The compinit
function finds all completion scripts provided by your installed command-line tools and prepares them for use.
This process is fast because Zsh creates a cache file (.zcompdump
). After the first run, your shell starts quickly by loading completions from this cache, only rebuilding it when you install new tools.