Skip to content

Commit

Permalink
display kube context in prompt
Browse files Browse the repository at this point in the history
Signed-off-by: Takashi Iiguni <[email protected]>
  • Loading branch information
guni1192 committed Nov 6, 2024
1 parent c01fd3e commit d7e7532
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion zsh/prompt.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ auth="%F{white}%K{black}%# %b%k"

precmd () {
vcs_info
export kube_current_context=""
context=$(kubectl config current-context)
if [[ "$context" =~ .*"prd".* ]] || [[ "$context" =~ .*"production".* ]]; then
export kube_current_context="%F{red}%K{black} $context %b%k"
else
export kube_current_context="%F{yellow}%K{black} $context %b%k"
fi
}

# RPROMPT='${vcs_info_msg_0_}'

PROMPT='$username$directory${vcs_info_msg_0_}$return_code
PROMPT='$username$directory${vcs_info_msg_0_}${kube_current_context}$return_code
$auth'

0 comments on commit d7e7532

Please sign in to comment.