Apple has delivered auto-completions for Zsh with the OS, but they seem to not be used…

The Fix

Edit ~/.zshrc with your favourite editor, like nano, and add the following two lines:

autoload -Uz compinit
compinit

Now save, exit, close and reopen your terminal.

Now your system utilities should have autocompletion!

Getting more auto-completions

If you’re using [MacPorts] you can install additional completions with:

sudo port install zsh-completions

Now add the following line to ~/.zshrc (above the previous ones we just added):

fpath=(/opt/local/share/zsh/site-functions $fpath)

The end-result should look like this:

fpath=(/opt/local/share/zsh/site-functions $fpath)
autoload -Uz compinit
compinit

Again, save, close, close and reopen your terminal.

Now you should have auto-completion for additional commands like the port command and more!

Clearing the cache

If you add additional auto-completions, but they don’t work, you might have to clear the cache and rebuild, you can do so with:

rm -f ~/.zcompdump; compinit

That’s all there is to it!

PS I run this blog on my free time, if I helped you out, consider donating a coffee!