50 lines
1.6 KiB
Bash
50 lines
1.6 KiB
Bash
# -*-mode: sh-*-
|
|
# My mess of various themes
|
|
# Optionally uses Zim modules git-info and duration-info
|
|
|
|
setopt nopromptbang promptcr promptpercent promptsp promptsubst
|
|
|
|
if [[ $(locale charmap) != UTF-8 || "$TERM" == linux ]]
|
|
then
|
|
ERROR_CHAR='<'
|
|
DIRTY_CHAR='^'
|
|
STASH_CHAR='≡' # ASCII 240
|
|
PREFIX='$'
|
|
else
|
|
ERROR_CHAR='⏎'
|
|
DIRTY_CHAR="∆" # U+2206
|
|
STASH_CHAR='📚' # U+1F4DA
|
|
PREFIX='❱' # U+2771
|
|
fi
|
|
|
|
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:keys' format \
|
|
'prompt' ' %F{yellow}%C%b%c%f%f%s' \
|
|
'rprompt' '%D%S'
|
|
|
|
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]}'
|