Skip to content

Instantly share code, notes, and snippets.

@superbrothers
Created July 26, 2017 14:28
Show Gist options
  • Save superbrothers/701f88472520fe3b6a3924ebeb1e18e5 to your computer and use it in GitHub Desktop.
Save superbrothers/701f88472520fe3b6a3924ebeb1e18e5 to your computer and use it in GitHub Desktop.
function peco-kubectl-context() {
local selected_context=$(kubectl config view -o go-template --template='{{range .contexts}}{{.name}}{{"\n"}}{{end}}' | peco --query "$LBUFFER")
if [ -n "$selected_context" ]; then
BUFFER="kubectl config use-context $selected_context"
zle accept-line
fi
zle clear-screen
}
zle -N peco-kubectl-context
bindkey '^K' peco-kubectl-context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment