mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-06-21 13:09:24 +00:00
support delete context interactively
This commit is contained in:
parent
11c19c0fb7
commit
7efe3b79d6
17
kubectx
17
kubectx
@ -124,6 +124,19 @@ choose_context_interactive() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete_contexts_interactive() {
|
||||||
|
local choice
|
||||||
|
choice="$(_KUBECTX_FORCE_COLOR=1 \
|
||||||
|
FZF_DEFAULT_COMMAND="${SELF_CMD}" \
|
||||||
|
fzf --ansi --no-preview || true)"
|
||||||
|
if [[ -z "${choice}" ]]; then
|
||||||
|
echo 2>&1 "error: you did not choose any of the options"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
delete_contexts "${choice}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
set_context() {
|
set_context() {
|
||||||
local prev
|
local prev
|
||||||
prev="$(current_context)" || exit_err "error getting current context"
|
prev="$(current_context)" || exit_err "error getting current context"
|
||||||
@ -211,9 +224,7 @@ main() {
|
|||||||
fi
|
fi
|
||||||
elif [[ "${1}" == "-d" ]]; then
|
elif [[ "${1}" == "-d" ]]; then
|
||||||
if [[ "$#" -lt 2 ]]; then
|
if [[ "$#" -lt 2 ]]; then
|
||||||
echo "error: missing context NAME" >&2
|
delete_contexts_interactive
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
delete_contexts "${@:2}"
|
delete_contexts "${@:2}"
|
||||||
elif [[ "$#" -gt 1 ]]; then
|
elif [[ "$#" -gt 1 ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user