Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support delete context interactively #406

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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