feat: custom p10k inspired kubectl PS1
This commit is contained in:
parent
5a4eba9519
commit
653ac5b89b
@ -70,7 +70,7 @@ zstyle ':omz:update' mode disabled # disable automatic updates
|
||||
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
|
||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||
# Add wisely, as too many plugins slow down shell startup.
|
||||
plugins=(vi-mode colored-man-pages kube-ps1 timer git gitignore)
|
||||
plugins=(vi-mode colored-man-pages git gitignore)
|
||||
|
||||
. "$ZSH"/oh-my-zsh.sh
|
||||
|
||||
|
@ -1,13 +1,36 @@
|
||||
PROMPT='
|
||||
$(kube_ps1)
|
||||
%(?::%{$fg_bold[red]%}%? )%{$fg_bold[cyan]%}%~%{$reset_color%} $(git_prompt_info)'
|
||||
KUBE_PS1_KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}"
|
||||
KUBE_PS1_KUBECONFIGMD5=
|
||||
KUBE_PS1_CTX=
|
||||
KUBE_PS1_NS=
|
||||
|
||||
_update_KUBE_PS1() {
|
||||
local md5="$(md5sum $KUBE_PS1_KUBECONFIG)"
|
||||
|
||||
[[ "$md5" == "$KUBE_PS1_KUBECONFIGMD5" ]] && return
|
||||
|
||||
KUBE_PS1_KUBECONFIGMD5="$md5"
|
||||
KUBE_PS1_CTX="$(kubectl config current-context)"
|
||||
KUBE_PS1_NS="$(kubectl config view --minify -o jsonpath='{..namespace}')"
|
||||
}
|
||||
|
||||
precmd() {
|
||||
_update_KUBE_PS1
|
||||
local ctx="$KUBE_PS1_CTX"
|
||||
local ns="$KUBE_PS1_NS"
|
||||
local symbol='\u2388 '
|
||||
local sep='/'
|
||||
local bg='\e[45m'
|
||||
local reset='\e[0m'
|
||||
#local end=" $reset\e[35m\ue0b4" #
|
||||
#local end=" $reset\e[35m\ue0bc" #
|
||||
local end=" $reset\e[35m\ue0b0" #
|
||||
|
||||
echo "$bg$symbol$ctx$sep$ns$end$reset"
|
||||
}
|
||||
|
||||
PROMPT='%(?::%{$fg_bold[red]%}%? )%{$fg_bold[cyan]%}%~%{$reset_color%} $(git_prompt_info)'
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}(%{$fg[red]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
|
||||
|
||||
KUBE_PS1_PREFIX=
|
||||
KUBE_PS1_SEPARATOR=' '
|
||||
KUBE_PS1_DIVIDER=/
|
||||
KUBE_PS1_SUFFIX=
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f4dc8c5be365668810783ced01a86ff8f251bfd7
|
||||
Subproject commit 29cf199b5d84eb4897f2e0e421a344174568eb9f
|
Loading…
Reference in New Issue
Block a user