From cac7e5b0b988bc5071ed756042ae527c75b5ef98 Mon Sep 17 00:00:00 2001 From: Ruize Tang <1466040111@qq.com> Date: Tue, 5 Jul 2022 16:28:06 +0800 Subject: [PATCH] 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. --- themes/jonathan.zsh-theme | 1 + 1 file changed, 1 insertion(+) diff --git a/themes/jonathan.zsh-theme b/themes/jonathan.zsh-theme index e8c490884..2ea23fa4e 100644 --- a/themes/jonathan.zsh-theme +++ b/themes/jonathan.zsh-theme @@ -7,6 +7,7 @@ function theme_precmd { local promptsize=${#${(%):---(%n@%m:%l)---()--}} local rubypromptsize=${#${(%)$(ruby_prompt_info)}} local pwdsize=${#${(%):-%~}} + pwdsize=$(($pwdsize * 3 - ${#${(ml[$pwdsize * 2])${(%):-%~}}})) # Truncate the path if it's too long. if (( promptsize + rubypromptsize + pwdsize > TERMWIDTH )); then