mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-06-25 15:02:21 +00:00
Merge 9a67d765c6
into 013b6bc252
This commit is contained in:
commit
814caa4ced
10
kubectx
10
kubectx
@ -108,14 +108,20 @@ save_context() {
|
||||
}
|
||||
|
||||
switch_context() {
|
||||
$KUBECTL config use-context "${1}"
|
||||
if ! $KUBECTL config use-context "${1}"; then
|
||||
if [[ -t 1 && -z "${KUBECTX_IGNORE_FZF:-}" && "$(type fzf &>/dev/null; echo $?)" -eq 0 ]]; then
|
||||
choose_context_interactive "${1}"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
choose_context_interactive() {
|
||||
local choice
|
||||
choice="$(_KUBECTX_FORCE_COLOR=1 \
|
||||
FZF_DEFAULT_COMMAND="${SELF_CMD}" \
|
||||
fzf --ansi --no-preview || true)"
|
||||
fzf --ansi --no-preview --query "${1:-}" --select-1 || true)"
|
||||
if [[ -z "${choice}" ]]; then
|
||||
echo 2>&1 "error: you did not choose any of the options"
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user