Skip to content

Instantly share code, notes, and snippets.

@jdharmon
Last active November 28, 2023 21:07
Show Gist options
  • Select an option

  • Save jdharmon/12f3928d476c1e77bc15aeee781f936d to your computer and use it in GitHub Desktop.

Select an option

Save jdharmon/12f3928d476c1e77bc15aeee781f936d to your computer and use it in GitHub Desktop.
PowerShell Kubectl & Helm Command Completion
# 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"
}
@termnml
Copy link

termnml commented Jun 6, 2021

This looks very clean.
Thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment