[K8S] kubectl enable autocomplete

  • Windows Powershell
# Powershell 5.x
echo 'Set-Alias -Name k -Value kubectl' >> $PROFILE
echo 'Register-ArgumentCompleter -CommandName k -ScriptBlock $__kubectlCompleterBlock'  >> $PROFILE
kubectl completion powershell >> $PROFILE
# Reload the PowerShell profile
. $PROFILE
  • Linux
# Install bash-completion
# > For Ubuntu Base  
sudo apt-get install bash-completion
# > For RHEL Base 
yum install bash-completion

# Add the completion script to your .bashrc file
echo 'source <(kubectl completion bash)' >>~/.bashrc

# Apply changes
source ~/.bashrc

Sample

Reference


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts to your email.