1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-10-16 11:40:46 +00:00

Compare commits

...

4 commits

Author SHA1 Message Date
Jérôme GARCIA
36fa8c117b
Merge 9346c2418c into f11cc8fea1 2024-09-23 07:37:43 +02:00
dependabot[bot]
f11cc8fea1
chore(deps): bump idna in /.github/workflows/dependencies (#12688)
Bumps [idna](https://github.com/kjd/idna) from 3.9 to 3.10.
- [Release notes](https://github.com/kjd/idna/releases)
- [Changelog](https://github.com/kjd/idna/blob/master/HISTORY.rst)
- [Commits](https://github.com/kjd/idna/compare/v3.9...v3.10)

---
updated-dependencies:
- dependency-name: idna
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-22 16:20:33 +02:00
sybernatus
9346c2418c
feat: add conditional formatting to agnoster
add conditional formatting for kubernetes to agnoster theme
2023-02-21 17:51:08 +01:00
alchazov
1fd41a3f8c Add KUBERNETES to prompt 2021-08-04 16:34:19 +05:00
2 changed files with 50 additions and 1 deletions

View file

@ -1,6 +1,6 @@
certifi==2024.8.30
charset-normalizer==3.3.2
idna==3.9
idna==3.10
PyYAML==6.0.2
requests==2.32.3
semver==3.0.2

View file

@ -254,6 +254,54 @@ prompt_aws() {
esac
}
#KUBERNETES icon:
# - display KUBERNETES icon if context set
# - displays red icon on black if context name contains 'prod'
# - displays green icon on black if context name contains 'dev' or 'stage'
# - displays yellow icon on black otherwise
prompt_kubernetes_icon() {
KUBERNETES_SYMBOL=$'\xE2\x8E\x88'
KUBERNETES_CONTEXT=$1
case "$KUBERNETES_CONTEXT" in
*prod*) prompt_segment black red "$KUBERNETES_SYMBOL";;
*dev*|*stage*) prompt_segment black green "$KUBERNETES_SYMBOL";;
*) prompt_segment black yellow "$KUBERNETES_SYMBOL";;
esac
}
#KUBERNETES context:
# - display current KUBERNETES context for connection
# - from file .kube/config or env $KUBECONFIG
# - displays kubernetes icon if $OMZ_THEME_AGNOSTER_KUBERNETES_ICON is not set to hidden
# - 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() {
KUBERNETES_BINARY="${KUBERNETES_BINARY:-kubectl}"
[[ -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_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_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"
fi
prompt_segment $CURRENT_BG default "$KUBERNETES_PROMPT"
fi
}
## Main prompt
build_prompt() {
RETVAL=$?
@ -262,6 +310,7 @@ build_prompt() {
prompt_aws
prompt_context
prompt_dir
prompt_kubernetes
prompt_git
prompt_bzr
prompt_hg