Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions kubectx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down