PowerShell kubectl autocomplete
kubectl has been shipping command completers for bash and ZSH for a while now. After taking a peek at the bash completion code I wrote a PowerShell port which I published as the PSKubectlCompletion Module in the PSGallery
.
To install PSKubectlCompletion
in PowerShell and register completions run the below commands:
After registering, hitting the Tab key for kubectl commands should generate completions.
PSKubectlCompletion
runs on PowerShell 5.1 and PowerShell Core v6.0 and higher. I had to upgrade PSReadline to v2.01 from beta on Linux to get it working just right.
The completion is done by binding kubectl.exe
as a Native command in the Register-ArgumentCompleter cmdlet.
If you want to take a look at the code or manually install the Module- Itβs up on GitHub. Give it a try and hit me up if you want to share feedback or contribute. If you use the awscli
and would like similar tab-completion checkout AWSCompleter as well.
βupdate: PSKubectlCompletion is no longer actively developed. kubectl has added PowerShell completion which you can now use. Thank you to everybody who contributed and used the project ππ½.