Skip to content

Instantly share code, notes, and snippets.

@lalyos
Last active November 25, 2018 12:35
Show Gist options
  • Save lalyos/608452e2507c2b5cf57a525db684789c to your computer and use it in GitHub Desktop.
Save lalyos/608452e2507c2b5cf57a525db684789c to your computer and use it in GitHub Desktop.
fix kubectl autocomplete
## usage: . <(curl -sL bit.ly/kubectl-fix)
if ! [[ "$KUBECTL_AUTOCOMP_FIXED" ]]; then
__kubectl_get_resource () { if [[ ${#nouns[@]} -eq 0 ]]; then local kubectl_out; if kubectl_out=$(kubectl api-resources $(__kubectl_override_flags) -o name --cached --verbs=get 2>/dev/null); then COMPREPLY=($( compgen -W "${kubectl_out[*]}" -- "$cur" )); return 0; fi; return 1; fi; __kubectl_parse_get "${nouns[${#nouns[@]} -1]}"; }
KUBECTL_AUTOCOMP_FIXED=1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment