fred-prompt/fred-prompt.zsh-theme

54 lines
1.5 KiB
Bash

# -*-mode: sh-*-
# My mess of various themes
# use extended color palette if available
: ${USER_COLOR=magenta}
: ${HOST_COLOR=yellow}
: ${PWD_COLOR=green}
: ${BRANCH_COLOR=yellow}
: ${DIRTY_COLOR=yellow}
setopt nopromptbang promptcr promptpercent promptsp promptsubst
if [[ $(locale charmap) != UTF-8 || "$TERM" == linux ]]
then
ERROR_CHAR=''
DIRTY_CHAR="*"
PREFIX='$'
else
ERROR_CHAR='⏎'
DIRTY_CHAR="∆" # U+2206
PREFIX="❱" # U+2771
fi
prompt_context() {
if [ -n "$SSH_CLIENT" ]
then
host=%B%F{blue}%m%f%b
else
host=%B%F{green}%m%f%b
fi
print "%B%(!.%F{red}.%F{green})%n@${host}"
}
typeset -gA git_info
if (( ${+functions[git-info]} )); then
zstyle ':zim:git-info' verbose yes
zstyle ':zim:git-info:branch' format '%b'
zstyle ':zim:git-info:commit' format '%c'
zstyle ':zim:git-info:action' format '%b%f:%F{${INDEXED_COLOR}}%B%a'
zstyle ':zim:git-info:dirty' format '%F{${INDEXED_COLOR}}${DIRTY_CHAR}%f'
if [[ -n ${STASHED_IND} ]]; then
zstyle ':zim:git-info:stashed' format '%F{${STASHED_COLOR}}${STASHED_IND}'
fi
zstyle ':zim:git-info:keys' format \
'prompt' ' %F{${BRANCH_COLOR}}%b%c%f%S%f%s' \
'rprompt' ' %D'
autoload -Uz add-zsh-hook && add-zsh-hook precmd git-info
fi
# Define prompts.
PS1='$(prompt_context)%F{cyan} %$((($COLUMNS-20) / 4 ))<..<%~%f${(e)git_info[prompt]}%(!. %B%F{red}#%f%b.)%B%F{cyan}${PREFIX}%f%b '
RPS1='${editor_info[overwrite]}%(?:: %F{red}%?'$ERROR_CHAR'%f) ${(e)git_info[rprompt]}'