Enable Auto Completion for Tanzu CLI on macOS with ZSH

Since I’ve been doing a larger then usual amount of work with TKG I wanted to enable auto completion. Tanzu cli provides the means for both zsh and bash shell’s, but I was running into an issue getting it to work with zsh on macOS, which is my default shell.

I searched for a good 30 minutes and couldn’t find anything online, which is why I’m blogging this. The closest I came was the velero documentation which has instructions for macOS and bash, but it was enough and lead in the right direction. Install zsh-completions via brew:

brew install zsh-completions

Add the following to your .zshrc:

if type brew &>/dev/null; then
    FPATH=$(brew --prefix)/share/zsh-completions:$FPATH

    autoload -Uz compinit

source <(tanzu completion zsh)

Reload your shell and your good to go.. Autocomplete with Tanzu should now be working.

This site uses Akismet to reduce spam. Learn how your comment data is processed.