Skip to content

Instantly share code, notes, and snippets.

@teivah
Created August 14, 2019 14:52
Show Gist options
  • Save teivah/7af135eca37e0865913d5a44abc980d1 to your computer and use it in GitHub Desktop.
Save teivah/7af135eca37e0865913d5a44abc980d1 to your computer and use it in GitHub Desktop.
#!/bin/bash
NORMAL="\[\e[00m\]"
BLACK="\[\e[0;30m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[0;32m\]"
YELLOW="\[\e[0;33m\]"
BLUE="\[\e[0;34m\]"
PURPLE="\[\e[0;35m\]"
CYAN="\[\e[0;36m\]"
WHITE="\[\e[0;37m\]"
function prompt_cmd
{
# Get current context
CONTEXT=$(cat ~/.kube/config | grep "current-context:" | sed "s/current-context: //")
if [ -n "$CONTEXT" ]; then
if [[ "$CONTEXT" == "prod-aws" ]]; then
export PS1="${BLUE}\W ${RED}\${CONTEXT}${NORMAL} \$ "
else
export PS1="${BLUE}\W ${YELLOW}\${CONTEXT}${NORMAL} \$ "
fi
fi
}
export PROMPT_COMMAND=prompt_cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment