Requires PR 105867
Plugin that generates shell completion scripts for over half the kubectl plugins.
$ kubectl krew install --manifest-url https://raw.githubusercontent.com/marckhouzam/kubectl-plugin_completion/v0.1.0/plugin-completion.yaml
$ kubectl plugin-completion generate
$ export PATH=$PATH:$HOME/.kubectl-plugin-completion
There is an ongoing effort to add support for shell completion for kubectl plugins. Please see kubernetes/kubernetes#105867 for details. If merged, it will be possible for any kubectl plugin to provide shell completion. However, each plugin will need to provide the necessary script itself; this will take time.
Until this happens, the plugin-completion
plugin automatically generates the required
shell completion scripts when possible, for the currently installed plugins.
This plugin is not (yet?) available on the Krew index, but can still be installed with Krew.
- Install the plugin:
kubectl krew install --manifest-url https://raw.githubusercontent.com/marckhouzam/kubectl-plugin_completion/v0.1.0/plugin-completion.yaml
- Add the
$HOME/.kubectl-plugin-completion
directory at the end of your$PATH
variable
kubectl plugin-completion generate
will generate completion scripts for all installed plugins that are supported. Once done, you will be able to do use shell completion with your plugins. For example:
$ kubectl plugin-completion generate
Shell completion for plugin 'krew' has been generated.
Shell completion for plugin 'plugin_completion' has been generated.
$ kubectl plugin-completion [tab][tab]
clean generate list supported
$ kubectl krew [tab][tab]
completion help index info install list search uninstall update upgrade version
After running this command, the plugin-completion
plugin itself will have shell completion enabled.
Note: Whenever you install a new plugin you will need to run the generate
command again.
kubectl plugin-completion clean
will remove all generated completion scripts.
kubectl plugin-completion list
will list the currently installed plugins for which a completion script has been generated.
kubectl plugin-completion supported
will list the installed plugins for which a shell completion script can be generated.
The plugin takes advantage of the fact that over 50% of plugins registered with krew use the Cobra library, which automatically supports shell completion. This plugin therefore automatically generates a shell completion script that uses Cobra's functionality.
You can find the generated scripts under $HOME/.kubectl-plugin-completion
.