nixos/modules/scripts/kctx.bash
Nickolaj Jepsen 575db8e773
Some checks failed
CI / fmt (push) Failing after 2s
CI / check (push) Failing after 2s
feat: add more scripts
2026-01-22 23:12:42 +01:00

21 lines
467 B
Bash

#!/usr/bin/env bash
set -euo pipefail
if ! command -v kubectl &> /dev/null; then
echo "kubectl not found"
exit 1
fi
CONTEXTS=$(kubectl config get-contexts -o name)
if [ -z "$CONTEXTS" ]; then
echo "No kubernetes contexts found"
exit 1
fi
SELECTED=$(echo "$CONTEXTS" | fzf --prompt="Kube Context > " --height=20% --layout=reverse)
if [ -n "$SELECTED" ]; then
kubectl config use-context "$SELECTED"
echo "Switched to context: $SELECTED"
fi