mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01: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:
parent
4c82a2eedf
commit
cac7e5b0b9
1 changed files with 1 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue