Last active
December 27, 2018 03:50
-
-
Save kaiix/f588bda19d3736ed425a109c378b2b23 to your computer and use it in GitHub Desktop.
This file contains 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
__kubectl_init_completion() | |
{ | |
COMPREPLY=() | |
_get_comp_words_by_ref "$@" cur prev words cword | |
} | |
__kubectl_get_pod() | |
{ | |
if declare -F _init_completion >/dev/null 2>&1; then | |
_init_completion -s || return | |
else | |
__kubectl_init_completion -n "=" || return | |
fi | |
local template | |
template="{{ range .items }}{{ .metadata.name }} {{ end }}" | |
local kubectl_out | |
if kubectl_out=$(kubectl get pod -o template --template="${template}" 2>/dev/null); then | |
COMPREPLY=( $( compgen -W "${kubectl_out[*]}" -- "$cur" ) ) | |
fi | |
} | |
kenter() | |
{ | |
kubectl exec -it $1 bash | |
} | |
complete -o default -o nospace -F __kubectl_get_pod kenter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment