Created
August 24, 2018 11:37
-
-
Save caruccio/6e1436c134372cc19dfd7a789f8c2ddf to your computer and use it in GitHub Desktop.
kubectl namespace switcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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