Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
65 lines (50 sloc) 1.52 KB
source ~/.kube-ps1
autoload -Uz colors && colors
setopt prompt_subst
prompt_symbol="✲"
green="%F{148}"
red="%F{202}"
directory="%F{226}"
function prompt_exit_status() {
if [ $? -eq 0 ]; then
echo "$green$prompt_symbol%{$reset_color%}"
else
echo "$red$prompt_symbol%{$reset_color%}"
fi
}
function prompt_git_branch() {
if git rev-parse --is-inside-work-tree &> /dev/null 2>&1; then
if git rev-parse HEAD &> /dev/null; then
local branch=$(git rev-parse --abbrev-ref HEAD)
if [[ $(git status) =~ "nothing to commit, working" ]]; then
echo -n "$green($branch)%{$reset_color%} "
else
echo -n "$red($branch)%{$reset_color%} "
fi
else
echo -n "${red}[EMPTY]%{$reset_color%} "
fi
fi
}
function prompt_directory() {
echo "$directory%~%{$reset_color%}"
}
function prompt_jobs() {
count=$( ( jobs ) | wc -l)
((count)) && echo -n "%F{250}[${count} hidden]%{$reset_color%} "
}
function prompt_aws() {
if [ -f ~/.aws/credentials ] || [ -n "$AWS_ACCESS_KEY_ID" ]; then
echo -n "%F{200}[AWS-ACTIVE]%{$reset_color%} "
fi
}
function google_cloud() {
if [ -e ~/.config/gcloud ]; then
echo -n "(\e[36m☁\e[0m |\e[36m$(cat ~/.config/gcloud/configurations/config_$(cat ~/.config/gcloud/active_config) | grep "project" | awk '{ print $3 }'))\e[0m "
fi
}
function prompt_kubectl() {
echo -n "[k8s namespace: $KC_NAMESPACE] "
}
export PROMPT='$(prompt_directory) $(prompt_jobs)$(prompt_aws)$(google_cloud)$(kube_ps1) $(prompt_git_branch)
$(prompt_exit_status) '