Files
website/content/en/docs/tasks/tools/included/optional-kubectl-configs-zsh.md
Marc Khouzam 0976014b7e No need for special handling for zsh aliases
Zsh completion is native since v1.22. Native zsh completion
automatically deals with aliases without needing
any extra configuration from the user.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
2022-03-04 13:57:49 -05:00

24 lines
750 B
Markdown

---
title: "zsh auto-completion"
description: "Some optional configuration for zsh auto-completion."
headless: true
---
The kubectl completion script for Zsh can be generated with the command `kubectl completion zsh`. Sourcing the completion script in your shell enables kubectl autocompletion.
To do so in all your shell sessions, add the following to your `~/.zshrc` file:
```zsh
source <(kubectl completion zsh)
```
If you have an alias for kubectl, kubectl autocompletion will automatically work with it.
After reloading your shell, kubectl autocompletion should be working.
If you get an error like `2: command not found: compdef`, then add the following to the beginning of your `~/.zshrc` file:
```zsh
autoload -Uz compinit
compinit
```