dotfiles/.local/bin/cx

12 lines
342 B
Plaintext
Raw Normal View History

2022-06-07 11:50:20 +02:00
#!/bin/bash
2022-06-08 21:23:51 +02:00
# cx - Kubernetes context switcher
2022-06-07 11:50:20 +02:00
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"