Compare commits

..

1 Commits

Author SHA1 Message Date
8400af9b8b WIP: migrate to .zsh-theme 2019-12-24 13:19:57 -05:00
2 changed files with 32 additions and 33 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
/*.zsh-theme.zwc*

View File

@ -1,53 +1,53 @@
# -*-mode: sh-*-
# My mess of various themes
# Optionally uses Zim modules git-info and duration-info
# 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 [[ "$TERM" != linux && \
("$LANG" =~ UTF-?8$ || \
"$(! (which locale > /dev/null) || locale charmap)" == UTF-8) ]]
if [[ $(locale charmap) != UTF-8 || "$TERM" == linux ]]
then
# assume we have UTF8 support
ERROR_CHAR=''
DIRTY_CHAR="*"
PREFIX='$'
else
ERROR_CHAR='⏎'
DIRTY_CHAR="∆" # U+2206
STASH_CHAR='📚' # U+1F4DA
PREFIX='❱' # U+2771
else
# fallback to ASCII
ERROR_CHAR='<'
DIRTY_CHAR='^'
STASH_CHAR='≡' # ASCII 240
PREFIX='$'
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:clean' format '%F{green}'
zstyle ':zim:git-info:branch' format '%b'
zstyle ':zim:git-info:commit' format '%c'
zstyle ':zim:git-info:action' format '%b%f:%F{yellow}%B%a'
zstyle ':zim:git-info:stashed' format "%S${STASH_CHAR}"
zstyle ':zim:git-info:dirty' format '%F{yellow}${DIRTY_CHAR}%f'
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{yellow}%C%b%c%f%f%s' \
'rprompt' '%D%S'
'prompt' ' %F{${BRANCH_COLOR}}%b%c%f%S%f%s' \
'rprompt' ' %D'
autoload -Uz add-zsh-hook && add-zsh-hook precmd git-info
fi
if (( ${+functions[duration-info-preexec]} )); then
zstyle ':zim:duration-info' threshold 1
zstyle ':zim:duration-info' format '(%d) '
add-zsh-hook preexec duration-info-preexec
add-zsh-hook precmd duration-info-precmd
fi
# Define prompts.
local userHost='%B%(!.%F{red}.%F{green})%n@${SSH_CLIENT:+%F{blue\}}%m%f%b' # user@host
local pathString='%F{cyan}%$((($COLUMNS-20) / 4 ))<..<%~%f' # /path/to/wd
local gitInfo='${(e)git_info[prompt]}' # branch:action
local promptChar='%B%(!.%F{red}.%F{cyan})${PREFIX}%f%b'
PS1="$userHost $pathString$gitInfo$promptChar "
RPS1='${editor_info[overwrite]}%(?:: %F{red}%?'$ERROR_CHAR'%f) ${duration_info}${(e)git_info[rprompt]}'
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]}'