Configure BASH Autocomplete for Kubectl CLI on MacOS X

Problem

When working with the Kubectl CLI often, it is much more efficient to be able to autocomplete long commands and resource names.

Environment

  • Platform9 Managed Kubernetes - All Versions
  • MacOS X - v10.13.x

Procedure

  1. Install the Homebrew binary.
command
Copy
  1. Install the bash-completion package.
command
Copy
  1. If you do not have a dedicated terminal and need to enable autocompletion on the fly, run the following command.
command
Copy

Otherwise, append the following command to your .zshrc file to enable autocomplete persistently.

command
Copy

If above command fails with error "Command not found: compdef" then run below command to load compinit:

Javascript
Copy

Additional Information

See Kubernetes Reference: Kubectl Cheat Sheet for more handy commands and configurations.

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard