kubectl provides autocompletion support for various operating systems such as Bash, Zsh, Fish, and Windows PowerShell. This can save a lot of typing and trying to remember the exact command format.
Setup kubectl Autocomplete in Windows
To enable kubectl autocomplete in Windows Powershell, run the following command in your Powershell terminal Window:
kubectl completion powershell | Out-String | Invoke-Expression
To save having to type this command every time you invoke a new terminal, you can add the command to your Powershell
To find the location of your
$PROFILE file, type the following command:
To edit your profile file directly from within Powershell, enter:
If the profile file is not present, you will be asked if you would like to create one. Add the command into the profile file and save. Close and re-open your Powershell terminal and autocomplete should be working.