1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-27 08:10:08 +00:00

fix(jonathan): set pwdsize to string display size

Some wide characters (e.g. CJK characters and emoji) have more than 1
size to display. If the PWD contains these characters, the prompt bar
size is not correctly calculated and the first line will be broken into
2 lines.
This commit is contained in:
Ruize Tang 2022-07-05 16:28:06 +08:00
parent 4c82a2eedf
commit cac7e5b0b9

View file

@ -7,6 +7,7 @@ function theme_precmd {
local promptsize=${#${(%):---(%n@%m:%l)---()--}} local promptsize=${#${(%):---(%n@%m:%l)---()--}}
local rubypromptsize=${#${(%)$(ruby_prompt_info)}} local rubypromptsize=${#${(%)$(ruby_prompt_info)}}
local pwdsize=${#${(%):-%~}} local pwdsize=${#${(%):-%~}}
pwdsize=$(($pwdsize * 3 - ${#${(ml[$pwdsize * 2])${(%):-%~}}}))
# Truncate the path if it's too long. # Truncate the path if it's too long.
if (( promptsize + rubypromptsize + pwdsize > TERMWIDTH )); then if (( promptsize + rubypromptsize + pwdsize > TERMWIDTH )); then