Erwin van Eyk bio photo

Erwin van Eyk

Software engineer and researcher.

Twitter LinkedIn Github

With the upcoming switch in MacOS to use Zsh rather than Bash, I decided to Zsh a shot as well for my setup. The setup (Zsh + oh-my-zsh) has been great so far. However, autocompletion for my alias of kubectl (k) using the common way to setup aliases with autocompletion caused a segfault in the shell.

alias k="kubectl"
alias compdef k="kubectl"

Since probably many people hit this issue at some point, I figured I’d share the workaround that I am using to have a kubectl alias with autocompletion.

So, to work around this issue, I sourced the autocompletion of kubectl manually, replacing the kubectl command with the k alias:

alias k="kubectl"
source <(kubectl completion zsh | sed 's/kubectl/k/g')