Skip to content

Shell Auto completion

Wenhao Ji edited this page Oct 11, 2026 · 4 revisions

TL;DR

  1. Upgrade kubectl tmux-exec to v0.4.0 or later.
  2. Upgrade kubectl to v1.26.0 or later.
  3. Enable the shell completion of kubectl.
  4. If the plugin is installed by Krew, follow the additional steps.

Step-by-Step

Here are the steps to enable it in your terminal.

Check the version of the plugin

Run the following command to check the version of the plugin.

kubectl tmux-exec --version

The version in the output must be 0.4.0 or later, for example:

0.5.0 (commit = ...)

If it is not, upgrade the plugin in the same way it was installed.

Homebrew

brew upgrade kubectl-tmux-exec

Krew

kubectl krew upgrade tmux-exec

Manually

Download the latest release.

Check the version of kubectl

kubectl version --client

The Client Version in the output must be v1.26.0 or later. Earlier versions do not support completion for plugins.

Client Version: v1.26.0
Kustomize Version: v4.5.7

If it is not, follow the official guide to upgrade kubectl.

Enable the shell completion of kubectl

The plugin completion is provided through the completion of kubectl itself, so it must be enabled first. Add the line for your shell to its startup file and restart the shell.

Bash (~/.bashrc)

source <(kubectl completion bash)

This requires the bash-completion package.

Zsh (~/.zshrc)

source <(kubectl completion zsh)

Fish (~/.config/fish/config.fish)

kubectl completion fish | source

See the kubectl documentation for more details. Run kubectl get <TAB> to check that it works.

Make sure the completion script is on the PATH

which kubectl_complete-tmux_exec

The output should look like this:

/usr/local/bin/kubectl_complete-tmux_exec

Additional Steps for Krew

Krew does not add the completion script to the PATH (see this issue for more information), so a symbolic link has to be created manually.

Replace v0.5.0 with the version you are using. Run ls "${KREW_ROOT:-$HOME/.krew}/store/tmux-exec/" to find it.

ln -sf "${KREW_ROOT:-$HOME/.krew}/store/tmux-exec/v0.5.0/bin/kubectl_complete-tmux_exec" "${KREW_ROOT:-$HOME/.krew}/bin/kubectl_complete-tmux_exec"

Then run which kubectl_complete-tmux_exec again to check that it is on the PATH.

Krew removes the old version after an upgrade, so run the command again with the new version after each kubectl krew upgrade tmux-exec.

Try it out

Type kubectl tmux-exec -- and press Tab. The options of the plugin should be listed.

Global flags of kubectl must come after the plugin name. For example, kubectl tmux-exec -n foo <TAB> works, but kubectl -n foo tmux-exec <TAB> does not.

If nothing is listed, run the following command to see what kubectl returns:

kubectl __complete tmux-exec ''