Skip to content

Instantly share code, notes, and snippets.

@caruccio
Created August 24, 2018 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caruccio/6e1436c134372cc19dfd7a789f8c2ddf to your computer and use it in GitHub Desktop.
Save caruccio/6e1436c134372cc19dfd7a789f8c2ddf to your computer and use it in GitHub Desktop.
kubectl namespace switcher
# Switch kubernetes namespaces withou touching ~/.kube/config
# Example:
#
# $ on kube-system
# NAME STATUS AGE
# kube-system Active 1y
# $ k get pod
#
on()
{
[ -n "$1" ] || return
kubectl get ns $1 || return
alias k="kubectl -n ${1:-default}"
if echo "$PS1" | \grep -q "^<<[^>]*>>" then
export PS1="${PS1/<<*>> /}"
fi;
export PS1="<<$1>> $PS1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment