94 lines
2.1 KiB
Plaintext
94 lines
2.1 KiB
Plaintext
|
|
function theme_precmd() {
|
|
local TERMWIDTH
|
|
(( TERMWIDTH = ${COLUMNS} - 1 ))
|
|
|
|
###
|
|
# Truncate the path if it's too long.
|
|
|
|
PR_FILLBAR=""
|
|
PR_PWDLEN=""
|
|
|
|
local promptsize=${#${(%):---(_________)---()--}}
|
|
local pwdsize=${#${(%):-%~}}
|
|
|
|
if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
|
|
((PR_PWDLEN=$TERMWIDTH - $promptsize))
|
|
else
|
|
PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
|
|
fi
|
|
|
|
vcs_info
|
|
}
|
|
|
|
setprompt () {
|
|
###
|
|
# Need this so the prompt will work.
|
|
|
|
setopt prompt_subst
|
|
|
|
autoload zsh/terminfo
|
|
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do
|
|
eval PR_$color='%F{${(L)color}}'
|
|
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
|
|
(( count = $count + 1 ))
|
|
done
|
|
PR_NO_COLOUR="%{$terminfo[sgr0]%}"
|
|
|
|
### UTF-8 Fixed
|
|
|
|
PR_SET_CHARSET=""
|
|
PR_SHIFT_IN=""
|
|
PR_SHIFT_OUT=""
|
|
PR_HBAR="─"
|
|
PR_ULCORNER="┌"
|
|
PR_LLCORNER="└"
|
|
PR_LRCORNER="┘"
|
|
PR_URCORNER="┐"
|
|
PR_EDGE="│"
|
|
|
|
###
|
|
|
|
PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
|
|
|
|
|
|
###
|
|
# Finally, the prompt.
|
|
|
|
|
|
PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
|
|
$PR_CYAN$PR_ULCORNER$PR_HBAR$PR_GREY(\
|
|
$PR_GREEN%$PR_PWDLEN<...<%~%<<\
|
|
$PR_GREY)$PR_CYAN$PR_HBAR$PR_HBAR${(e)PR_FILLBAR}$PR_HBAR$PR_GREY(\
|
|
$PR_GREEN%D{%a,%b%d}$PR_GREY)$PR_CYAN$PR_HBAR$PR_URCORNER\
|
|
|
|
$PR_EDGE %1(j.%j job%2(j.s.) running.)\
|
|
|
|
$PR_CYAN$PR_LLCORNER$PR_BLUE$PR_HBAR(\
|
|
$PR_YELLOW%D{%H:%M:%S}\
|
|
$PR_LIGHT_BLUE%{$reset_color%}$PR_BLUE)$PR_CYAN$PR_HBAR\
|
|
$PR_HBAR\
|
|
>$PR_NO_COLOUR '
|
|
|
|
# display exitcode on the right when >0
|
|
return_code="%(?.%F{green}✓.%F{red%}%? ↵ %{$reset_color%})"
|
|
RPROMPT=' $return_code \
|
|
$PR_BLUE($PR_YELLOW${vcs_info_msg_0_}$PR_BLUE)$PR_HBAR$PR_CYAN$PR_LRCORNER$PR_NO_COLOUR'
|
|
|
|
PS2='$PR_CYAN$PR_HBAR\
|
|
$PR_BLUE$PR_HBAR(\
|
|
$PR_LIGHT_GREEN%_$PR_BLUE)$PR_HBAR\
|
|
$PR_CYAN$PR_HBAR$PR_NO_COLOUR '
|
|
}
|
|
|
|
setprompt
|
|
|
|
autoload -U add-zsh-hook
|
|
autoload -Uz vcs_info
|
|
|
|
|
|
add-zsh-hook precmd theme_precmd
|
|
|
|
zstyle ':vcs_info:git*' formats "%b"
|
|
zstyle ':vcs_info:git*' actionformats "%b"
|