Last active
November 28, 2023 21:07
-
-
Save jdharmon/12f3928d476c1e77bc15aeee781f936d to your computer and use it in GitHub Desktop.
PowerShell Kubectl & Helm Command Completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Setup | |
| Install-Module -Name PSBashCompletions -Scope CurrentUser | |
| $path = (mkdir (Join-Path (Split-Path -Parent $PROFILE) Completion)).FullName | |
| ((kubectl completion bash) -join "`n") | Set-Content -Encoding ASCII -NoNewline -Path $path/kubectl.sh | |
| ((helm completion bash) -join "`n") | Set-Content -Encoding ASCII -NoNewline -Path $path/helm.sh | |
| # Profile | |
| $completionPath = Join-Path (Split-Path -Parent $PROFILE) Completion | |
| if (Test-Path $completionPath) { | |
| Import-Module PSBashCompletions | |
| Register-BashArgumentCompleter kubectl "$completionPath/kubectl.sh" | |
| Register-BashArgumentCompleter kc "$completionPath/kubectl.sh" | |
| Register-BashArgumentCompleter helm "$completionPath/helm.sh" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This looks very clean.
Thanks for sharing.