FEATURE REQUEST
It would be great to see autocompletion support for PowerShell. Is it possible for Windows releases?
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
The following module offer tab completion of kubectl within PowerShell Core
https://github.com/felixfbecker/PSKubectl
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle rotten
/area kubectl
/sig cli
/kind feature
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
/remove-lifecycle stale
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
/remove-lifecycle stale
I use kubectl every day, and it would be a great enhancement to have a powershell-native module (PS core, of course! cross platform et al). Right now we are stuck with the outdated cmd shell. For example, instead of returning yaml or json string on the stdout, the cmdlet could return rich objects that we could interact with easily.
@RoguePointer80 This is what you look for: https://github.com/felixfbecker/PSKubectl
If you're looking for kubectl auto-completion in PowerShell you can have a look at PSKubectlCompletion module- https://www.powershellgallery.com/packages/PSKubectlCompletion
/priority backlog
It would be amazing if we can have the auto completion like on bash
For eg pod names. Namespaces etc
I really like the way the WinGet team did it. I'm sure I've also seen this pattern elsewhere.
"complete" is a command on the cli tool itself, which handles the auto-completion. It can then we wrapped by any shell's auto-complete mechanism, will always be up-to-date with the application itself, and can probably re-use most of the code the cli tool already uses for determining commands.
It would also make the existing shell completions for BASH/ZSH simpler and easier to maintain, as they would now simply call the CLI itself. Also means the shell completions don't need to be updated when the CLI commands change.
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
[Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
$Local:word = $wordToComplete.Replace('"', '""')
$Local:ast = $commandAst.ToString().Replace('"', '""')
winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
I presume the BASH completion function would become equally short, instead of the 13,000 lines it is now.
There are two cool options listed in this issue, but I consider them both proofs of concept.
https://github.com/felixfbecker/PSKubectl requires you to use an entirely new command syntax, which is not desirable
https://www.powershellgallery.com/packages/PSKubectlCompletion is a good start, but does not support resource name completion as of yet (there's an open issue for it).
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
/remove-lifecycle stale
As information, the next release of Cobra, the library beneath kubectl, will provide support for powershell completion:
https://github.com/spf13/cobra/pull/1208
That's dope.
Cobra 1.1.3 has been released and provides full PowerShell completion support. Kubectl could start using it for commands and flags.
However, custom completions that are defined directly in kubectl (e.g., kubectl get [tab], kubectl describe pod [tab], etc) will only work for PowerShell if they are moved to Go completions which is done in kubernetes/kubernetes#96087
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
/remove-lifecycle stale
Most helpful comment
As information, the next release of Cobra, the library beneath kubectl, will provide support for powershell completion:
https://github.com/spf13/cobra/pull/1208