mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-22 07:43:31 +01:00
feat: add conditional formatting to agnoster
add conditional formatting for kubernetes to agnoster theme
This commit is contained in:
parent
1fd41a3f8c
commit
9346c2418c
@ -261,30 +261,44 @@ prompt_kubernetes_icon() {
|
|||||||
#KUBERNETES context:
|
#KUBERNETES context:
|
||||||
# - display current KUBERNETES context for connection
|
# - display current KUBERNETES context for connection
|
||||||
# - from file .kube/config or env $KUBECONFIG
|
# - from file .kube/config or env $KUBECONFIG
|
||||||
# - displays context name
|
# - displays kubernetes icon if $OMZ_THEME_AGNOSTER_KUBERNETES_ICON is not set to hidden
|
||||||
# - displays namespace if set
|
# - displays context name if $OMZ_THEME_AGNOSTER_KUBERNETES_CONTEXT is not set to hidden
|
||||||
|
# - displays namespace if $OMZ_THEME_AGNOSTER_KUBERNETES_NAMESPACE is not set to hidden
|
||||||
prompt_kubernetes() {
|
prompt_kubernetes() {
|
||||||
KUBERNETES_BINARY="${KUBERNETES_BINARY:-kubectl}"
|
KUBERNETES_BINARY="${KUBERNETES_BINARY:-kubectl}"
|
||||||
[[ -z "$KUBECONFIG" && -z "$(${KUBERNETES_BINARY} config current-context 2>/dev/null)" ]] && return
|
[[ -z "$KUBECONFIG" && -z "$(${KUBERNETES_BINARY} config current-context 2>/dev/null)" ]] && return
|
||||||
|
|
||||||
|
KUBERNETES_PROMPT=""
|
||||||
|
|
||||||
|
if [[ "$OMZ_THEME_AGNOSTER_KUBERNETES_CONTEXT" != "hidden" ]]; then
|
||||||
KUBERNETES_CONTEXT="$(${KUBERNETES_BINARY} config current-context 2>/dev/null)"
|
KUBERNETES_CONTEXT="$(${KUBERNETES_BINARY} config current-context 2>/dev/null)"
|
||||||
KUBERNETES_CONTEXT="${KUBERNETES_CONTEXT:-N/A}"
|
KUBERNETES_CONTEXT="${KUBERNETES_CONTEXT:-N/A}"
|
||||||
|
KUBERNETES_PROMPT="$KUBERNETES_PROMPT$KUBERNETES_CONTEXT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$OMZ_THEME_AGNOSTER_KUBERNETES_NAMESPACE" != "hidden" ]]; then
|
||||||
KUBERNETES_NAMESPACE="$(${KUBERNETES_BINARY} config view --minify -o jsonpath={..namespace} 2>/dev/null)"
|
KUBERNETES_NAMESPACE="$(${KUBERNETES_BINARY} config view --minify -o jsonpath={..namespace} 2>/dev/null)"
|
||||||
KUBERNETES_NAMESPACE="${KUBERNETES_NAMESPACE:+ ns:$KUBERNETES_NAMESPACE}"
|
KUBERNETES_NAMESPACE="${KUBERNETES_NAMESPACE:+ ns:$KUBERNETES_NAMESPACE}"
|
||||||
|
KUBERNETES_PROMPT="$KUBERNETES_PROMPT -$KUBERNETES_NAMESPACE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$KUBERNETES_PROMPT" != "" ]]; then
|
||||||
|
if [[ "$OMZ_THEME_AGNOSTER_KUBERNETES_ICON" != "hidden" ]]; then
|
||||||
prompt_kubernetes_icon "$KUBERNETES_CONTEXT"
|
prompt_kubernetes_icon "$KUBERNETES_CONTEXT"
|
||||||
prompt_segment $CURRENT_BG default "$KUBERNETES_CONTEXT$KUBERNETES_NAMESPACE"
|
fi
|
||||||
|
prompt_segment $CURRENT_BG default "$KUBERNETES_PROMPT"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Main prompt
|
## Main prompt
|
||||||
build_prompt() {
|
build_prompt() {
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
prompt_status
|
prompt_status
|
||||||
prompt_kubernetes
|
|
||||||
prompt_virtualenv
|
prompt_virtualenv
|
||||||
prompt_aws
|
prompt_aws
|
||||||
prompt_context
|
prompt_context
|
||||||
prompt_dir
|
prompt_dir
|
||||||
|
prompt_kubernetes
|
||||||
prompt_git
|
prompt_git
|
||||||
prompt_bzr
|
prompt_bzr
|
||||||
prompt_hg
|
prompt_hg
|
||||||
|
Loading…
Reference in New Issue
Block a user