mirror of https://gitlab.com/dabruh/dotfiles.git
12 lines
342 B
Bash
Executable File
12 lines
342 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# cx - Kubernetes context switcher
|
|
|
|
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"
|