dotar/zsh/prezto-themes/prompt_skwp_setup
2021-02-21 16:53:21 +08:00

76 lines
2.0 KiB
Plaintext

#
# A theme based on steeef theme
# * RVM/Rbenv info shown on the right
# * Git branch info on the left
# * Single line prompt
#
# Authors:
# Steve Losh <steve@stevelosh.com>
# Bart Trojanowski <bart@jukie.net>
# Brian Carper <brian@carper.ca>
# steeef <steeef@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
# Yan Pritzker <yan@pritzker.ws>
function prompt_skwp_precmd {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
# Get Git repository information.
if [[ $DISABLE_GIT_INFO == 1 ]]; then
git-info off
elif [[ $+functions[git-info] ]]; then
git-info on
git-info
fi
}
function prompt_skwp_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent sp subst)
autoload -Uz add-zsh-hook
add-zsh-hook precmd prompt_skwp_precmd
# Use extended color pallete if available.
if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
__PROMPT_SKWP_COLORS=(
"%F{81}" # turquoise
"%F{166}" # orange
"%F{135}" # purple
"%F{161}" # hotpink
"%F{118}" # limegreen
)
else
__PROMPT_SKWP_COLORS=(
"%F{cyan}"
"%F{yellow}"
"%F{magenta}"
"%F{red}"
"%F{green}"
)
fi
# git
zstyle ':prezto:module:git:info:branch' format "${__PROMPT_SKWP_COLORS[1]}%b%f"
zstyle ':prezto:module:git:info:added' format "${__PROMPT_SKWP_COLORS[5]}●%f"
zstyle ':prezto:module:git:info:deleted' format "${__PROMPT_SKWP_COLORS[2]}●%f"
zstyle ':prezto:module:git:info:modified' format "${__PROMPT_SKWP_COLORS[4]}●%f"
zstyle ':prezto:module:git:info:untracked' format "${__PROMPT_SKWP_COLORS[3]}●%f"
zstyle ':prezto:module:git:info:keys' format 'prompt' '(%b%d%a%m%u)'
PROMPT="${__PROMPT_SKWP_COLORS[3]}%n%f ${__PROMPT_SKWP_COLORS[5]}%~%f "'$git_info[prompt]'"$ "
[[ "$KCONTEXT" != "" ]] && PROMPT="%F{blue}$KCONTEXT $PROMPT"
RPROMPT='%F{blue}'
}
alias disable_git_info='DISABLE_GIT_INFO=1'
alias enable_git_info='DISABLE_GIT_INFO=0'
function set_k8s_context {
set_k8s_context_core $*
prompt_skwp_setup
}
prompt_skwp_setup