-
-
Save chy168/ad285f18964c3f5a6272af786ff8255b to your computer and use it in GitHub Desktop.
zsh theme for display kube context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Pre-install package | |
https://github.com/jonmosco/kube-ps1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*%{$fg[green]%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="" | |
function zz_git_prompt_info() { | |
if command git rev-parse --git-dir &>/dev/null; then | |
echo "$ZSH_THEME_GIT_PROMPT_PREFIX$(git_current_branch) ➼ $(git_prompt_short_sha)$ZSH_THEME_GIT_PROMPT_SUFFIX" | |
fi | |
} | |
function get_cluster_short() { | |
OT="" | |
if [[ $1 == *"eks"* ]]; then | |
CLUSTER_NAME=`echo $1 | cut -d / -f2` | |
OT="EKS/${CLUSTER_NAME}" | |
fi | |
if [[ $1 == *"gke"* ]]; then | |
CLUSTER_NAME=`echo $1 | cut -d _ -f2` | |
OT="GKE/${CLUSTER_NAME}" | |
fi | |
echo $OT | |
# echo "$1" | cut -d / -f2 | |
} | |
KUBE_PS1_CLUSTER_FUNCTION=get_cluster_short | |
KUBE_PS1_NS_ENABLE=false | |
KUBE_PS1_SYMBOL_DEFAULT="🤟" | |
PROMPT=$'%{$fg_bold[green]%}%n %{$fg[blue]%}%{$reset_color%}%{$fg[white]%}[%~]%{$reset_color%} $(zz_git_prompt_info) $(kube_ps1)\ | |
%{$fg[blue]%}->%{$fg_bold[blue]%} %#%{$reset_color%} ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment