1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-18 02:20:09 +00:00

fix(jonathan): fix top bar alignment with RPROMPT

This commit is contained in:
Marc Cornellà 2021-12-16 10:51:25 +01:00
parent 4b4cc9a4a5
commit 41c15a2159
No known key found for this signature in database
GPG key ID: 0314585E776A9C1B

View file

@ -1,4 +1,6 @@
function theme_precmd { function theme_precmd {
local TERMWIDTH=$(( COLUMNS - ${ZLE_RPROMPT_INDENT:-1} ))
PR_FILLBAR="" PR_FILLBAR=""
PR_PWDLEN="" PR_PWDLEN=""
@ -7,12 +9,12 @@ function theme_precmd {
local pwdsize=${#${(%):-%~}} local pwdsize=${#${(%):-%~}}
# Truncate the path if it's too long. # Truncate the path if it's too long.
if (( promptsize + rubypromptsize + pwdsize > COLUMNS )); then if (( promptsize + rubypromptsize + pwdsize > TERMWIDTH )); then
(( PR_PWDLEN = COLUMNS - promptsize )) (( PR_PWDLEN = TERMWIDTH - promptsize ))
elif [[ "${langinfo[CODESET]}" = UTF-8 ]]; then elif [[ "${langinfo[CODESET]}" = UTF-8 ]]; then
PR_FILLBAR="\${(l:$(( COLUMNS - (promptsize + rubypromptsize + pwdsize) ))::${PR_HBAR}:)}" PR_FILLBAR="\${(l:$(( TERMWIDTH - (promptsize + rubypromptsize + pwdsize) ))::${PR_HBAR}:)}"
else else
PR_FILLBAR="${PR_SHIFT_IN}\${(l:$(( COLUMNS - (promptsize + rubypromptsize + pwdsize) ))::${altchar[q]:--}:)}${PR_SHIFT_OUT}" PR_FILLBAR="${PR_SHIFT_IN}\${(l:$(( TERMWIDTH - (promptsize + rubypromptsize + pwdsize) ))::${altchar[q]:--}:)}${PR_SHIFT_OUT}"
fi fi
} }