mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-06-01 03:45:59 +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
|
||||
}
|
||||
|
||||
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() {
|
||||
local prev
|
||||
prev="$(current_context)" || exit_err "error getting current context"
|
||||
@ -211,9 +224,7 @@ main() {
|
||||
fi
|
||||
elif [[ "${1}" == "-d" ]]; then
|
||||
if [[ "$#" -lt 2 ]]; then
|
||||
echo "error: missing context NAME" >&2
|
||||
usage
|
||||
exit 1
|
||||
delete_contexts_interactive
|
||||
fi
|
||||
delete_contexts "${@:2}"
|
||||
elif [[ "$#" -gt 1 ]]; then
|
||||
|
Loading…
Reference in New Issue
Block a user