Created
October 10, 2016 13:25
-
-
Save micahhausler/0d8646da95ad0a258fb8a6521fc35224 to your computer and use it in GitHub Desktop.
Kubernetes PS1
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
NORMAL="\[\033[00m\]" | |
BLUE="\[\033[01;34m\]" | |
RED="\[\e[1;31m\]" | |
YELLOW="\[\e[1;33m\]" | |
GREEN="\[\e[1;32m\]" | |
PS1_WORKDIR="\w" | |
PS1_HOSTNAME="\h" | |
PS1_USER="\u" | |
__kube_ps1() | |
{ | |
CONTEXT=$(kubectl config current-context) | |
if [ -n "$CONTEXT" ]; then | |
case "$CONTEXT" in | |
*prod*) | |
echo "${RED}(k8s: ${CONTEXT})" | |
;; | |
*test*) | |
echo "${YELLOW}(k8s: ${CONTEXT})" | |
;; | |
*) | |
echo "${GREEN}(k8s: ${CONTEXT})" | |
;; | |
esac | |
fi | |
} | |
export PROMPT_COMMAND='PS1="${GREEN}${PS1_USER}@${PS1_HOSTNAME}${NORMAL}:$(__kube_ps1)${BLUE}${PS1_WORKDIR}${NORMAL}\$ "' | |
# See https://twitter.com/micahhausler/status/785204875613261824 for example output |
Author
micahhausler
commented
Oct 11, 2016
For those who like fancy unicode stuff in their prompt, ☸ looks sorta like the Kubernetes logo, especially when colored correctly.
or you can ⌃+⌘+SPACE
then type helm
and get: ⎈
forked powerline-docker
and created https://github.com/so0k/powerline-kubernetes
other cool stuff kubectl
can do
https://gist.github.com/so0k/42313dbb3b547a0f51a547bb968696ba
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment