Kubernetes context switcher.

This commit is contained in:
dabruh 2022-06-07 11:50:20 +02:00
parent 894b653cd1
commit 8e5a901947
1 changed files with 9 additions and 0 deletions

9
.local/bin/cx Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
LAST=/tmp/last_kube_context
CURR="$(kubectl config current-context)"
[[ -z "$1" ]] && kubectl config get-contexts && exit
[ ! -f $LAST ] && echo "$CURR" >$LAST
[[ "$1" == "-" ]] && USE="$(cat $LAST)" || USE="$1"
[[ "$CURR" != "$USE" ]] && echo "$CURR" >$LAST
kubectl config use-context "$USE"