kubectl Verified current stable Not installed? Kubernetes

Kubectl / Print Completion Script Bash Zsh Fish Powershell

Print Completion Script Bash Zsh Fish Powershell

Use kubectl to generate shell completion scripts for bash, zsh, fish, or PowerShell.

$
Terminal
kubectl completion <bash|zsh|fish|powershell>

When To Use

Use this command to enable command-line autocompletion for kubectl in your shell.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
kubectl completion <bash|zsh|fish|powershell>

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
# For bash:
echo 'source <(kubectl completion bash)'

# For zsh:
echo 'source <(kubectl completion zsh)'

# For fish:
echo 'kubectl completion fish | source'

# For PowerShell:
echo 'kubectl completion powershell | Out-String | Invoke-Expression'

Power User Variants

Optimized versions

kubectl completion bash

Generate completion script for bash.

kubectl completion zsh

Generate completion script for zsh.

kubectl completion fish

Generate completion script for fish.

Unix Pipeline

Shell combinations

kubectl completion powershell

Generate completion script for PowerShell.

Command Breakdown

What each part is doing

kubectl
Base Command
The executable that performs this operation. Here it runs Kubectl before the shell applies any redirect operators.
<bash|zsh|fish|powershell>
bash|zsh|fish|powershell
The value supplied for bash|zsh|fish|powershell.

How To Run

Execution path

  1. Step 1

    Run the command with your desired shell type: bash, zsh, fish, or powershell.

  2. Step 2

    Follow the output instructions to enable completion in your shell configuration.

  3. Step 3

    Restart your terminal or source your configuration file to apply changes.

Alternative Approaches

Comparable commands in other tools

Alternative kubernetes tools for the same job.