Nick's Blog

Set up istioctl auto completion for ZSH

After testing istio in my side project for a while, finally one of the customers is keen to give istio a go. Because the client is using Azure. So first thing first, I need to get istio installed in Kubernetes cluster. Unlike GCP, you can sort of tick to enable istio. For Azure there is no option to do that. So I was following the documentation try to get it done via istioctl.

For istioctl auto completion, the documentation only gives the instruction on bash. Because I was using zsh on Mac. So just adding this extra bits for ZSH.

You need to get your istioctl downloaded and put into /usr/local/bin, and then run the following command.

# Generate the bash completion file and source it in your current shell
mkdir -p ~/completions && istioctl collateral --zsh -o ~/completions
source ~/completions/_istioctl

# Source the bash completion file in your .bashrc so that the command-line completions
# are permanently available in your shell
echo "source ~/completions/_istioctl" >> ~/.zshrc

While I was setting things up I was getting unknown source error for zsh as well. And that one is due to I download a linux binary instead of mac. Pay extra care for that as well.