From 862bfc81d2c422ec97336fdb577e22b50fad2a11 Mon Sep 17 00:00:00 2001 From: Jijeesh Date: Sat, 11 May 2024 21:29:46 +0530 Subject: [PATCH 1/2] create jijeesh Theme --- themes/jijeesh.zsh-theme | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 themes/jijeesh.zsh-theme diff --git a/themes/jijeesh.zsh-theme b/themes/jijeesh.zsh-theme new file mode 100644 index 000000000000..02868c85f51d --- /dev/null +++ b/themes/jijeesh.zsh-theme @@ -0,0 +1,59 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# jijeesh Theme - https://github.com/jijeesh/kubectl-aliases/blob/master/README.md +# A Powerline-inspired theme for ZSH +# +# # README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts). + +local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" + +function toon { + local os_type="$(uname -s)" + case "${os_type}" in + "Darwin") echo -n "🍎" ;; # macOS + "Linux") echo -n "🐧" ;; # Linux (Ubuntu) + *) echo -n "♔" ;; # Default emoji for unknown OS + esac +} + + +function k8sSymbol { + echo -n " ☸ " +} +function gitSymbol { + echo -n " \uE0A0 " +} + +function kubect_prompt_info() { + local kubectl_prompt="$(kubectl config current-context)" + local kgnc_prompt="$(kubectl config view --minify --output 'jsonpath={..namespace}')" + # prompt_segment blue yellow + echo -n "${ZSH_THEME_KUBECTL_PROMPT_PREFIX}${kgnc_prompt}${ZSH_THEME_KUBECTL_PROMPT_SUFFIX}" +} + +if [[ $UID -eq 0 ]]; then + local user_host='%{$terminfo[bold]$fg[red]%}%n@%m %{$reset_color%}' + local user_symbol='#' +else + local user_host='%{$terminfo[bold]$fg[green]%}%n %{$reset_color%}' + local user_symbol='$' +fi + +if [ -d ~/.kube ]; then +local k8s_symbol='%{$fg_bold[blue]%}$(k8sSymbol) $(kubect_prompt_info) %{$reset_color%}' +fi +local current_dir='%{$fg_bold[red]%}$(toon)% %{$terminfo[bold]$fg_bold[yellow]%}%~ %{$reset_color%}' +local git_branch='$(git_prompt_info)' + + + +PROMPT="╭─${user_host}${k8s_symbol}${git_branch} +${current_dir} +╰─%B${user_symbol}%b " +RPROMPT="%B${return_code}%b" +ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_bold[red]%}$(gitSymbol)%{$reset_color%}%{$fg_bold[red]%} " +ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}" + From 565d9ec2832e4c71d19b13c1905b62c58df32b6b Mon Sep 17 00:00:00 2001 From: Jijeesh Date: Sat, 11 May 2024 21:41:10 +0530 Subject: [PATCH 2/2] create jijeesh Theme --- themes/jijeesh.zsh-theme | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/themes/jijeesh.zsh-theme b/themes/jijeesh.zsh-theme index 02868c85f51d..2487f62ae7fe 100644 --- a/themes/jijeesh.zsh-theme +++ b/themes/jijeesh.zsh-theme @@ -8,52 +8,64 @@ # In order for this theme to render correctly, you will need a # [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts). +# Return code indicator local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" +# Function to determine system emoji function toon { - local os_type="$(uname -s)" - case "${os_type}" in + case "$(uname -s)" in "Darwin") echo -n "🍎" ;; # macOS - "Linux") echo -n "🐧" ;; # Linux (Ubuntu) - *) echo -n "♔" ;; # Default emoji for unknown OS + "Linux") echo -n "🐧" ;; # Linux (Ubuntu) + *) echo -n "♔" ;; # Default emoji for unknown OS esac } - +# Function to display Kubernetes symbol function k8sSymbol { echo -n " ☸ " } + +# Function to display Git symbol function gitSymbol { echo -n " \uE0A0 " } +# Function to get Kubernetes prompt info function kubect_prompt_info() { local kubectl_prompt="$(kubectl config current-context)" local kgnc_prompt="$(kubectl config view --minify --output 'jsonpath={..namespace}')" - # prompt_segment blue yellow echo -n "${ZSH_THEME_KUBECTL_PROMPT_PREFIX}${kgnc_prompt}${ZSH_THEME_KUBECTL_PROMPT_SUFFIX}" } +# User and host prompt if [[ $UID -eq 0 ]]; then - local user_host='%{$terminfo[bold]$fg[red]%}%n@%m %{$reset_color%}' - local user_symbol='#' + local user_host='%{$terminfo[bold]$fg[red]%}%n@%m %{$reset_color%}' + local user_symbol='#' else - local user_host='%{$terminfo[bold]$fg[green]%}%n %{$reset_color%}' - local user_symbol='$' + local user_host='%{$terminfo[bold]$fg[green]%}%n %{$reset_color%}' + local user_symbol='$' fi +# Kubernetes symbol display if ~/.kube directory exists if [ -d ~/.kube ]; then -local k8s_symbol='%{$fg_bold[blue]%}$(k8sSymbol) $(kubect_prompt_info) %{$reset_color%}' + local k8s_symbol='%{$fg_bold[blue]%}$(k8sSymbol) $(kubect_prompt_info) %{$reset_color%}' fi -local current_dir='%{$fg_bold[red]%}$(toon)% %{$terminfo[bold]$fg_bold[yellow]%}%~ %{$reset_color%}' -local git_branch='$(git_prompt_info)' +# Current directory prompt +local current_dir='%{$fg_bold[red]%}$(toon)% %{$terminfo[bold]$fg_bold[yellow]%}%~ %{$reset_color%}' +# Git branch prompt +local git_branch='$(git_prompt_info)' +# Main prompt setup PROMPT="╭─${user_host}${k8s_symbol}${git_branch} ${current_dir} ╰─%B${user_symbol}%b " + + +# Right prompt setup RPROMPT="%B${return_code}%b" -ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_bold[red]%}$(gitSymbol)%{$reset_color%}%{$fg_bold[red]%} " -ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}" +# Git prompt configuration +ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_bold[red]%}$(gitSymbol)%{$reset_color%}%{$fg_bold[red]%} " +ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}" \ No newline at end of file