This commit is contained in:
Austin 2025-02-20 06:14:58 +01:00 committed by GitHub
commit 65fb509d85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 0 deletions

View File

@ -350,11 +350,27 @@ prompt_aws() {
esac
}
prompt_kubecontext() {
[[ -z "$(which kubectl)" ]] && return
local kube_prompt="k8s: "
local current_context="$(kubectl config current-context)"
local current_namespace="$(kubectl config get-contexts --no-headers | grep '*' | awk '{print $5}')"
[[ -z "${current_context}" ]] && return
kube_prompt+="${current_context}"
[[ "${current_namespace}" ]] && [[ "${current_namespace}" != "default" ]]&& kube_prompt+="/${current_namespace}"
case "$kube_prompt" in
*prod*|*production*) prompt_segment red black "${kube_prompt}" ;;
*) prompt_segment cyan $CURRENT_FG "${kube_prompt}" ;;
esac
}
## Main prompt
build_prompt() {
RETVAL=$?
prompt_status
prompt_virtualenv
prompt_kubecontext
prompt_aws
prompt_context
prompt_dir