fix(josh): escape % in branch name before computing branch_size

c90141e introduced %-escaping in the prompt string via ${branch//\%/%%}
but branch_size was still computed from the raw (unescaped) branch name.
For branch names containing %, branch_size underestimates the displayed
width by one per % character, shifting all right-side padding one space
too wide.

Move the escaping to immediately after git_current_branch so that
branch_size and the prompt string both use the escaped length.
This commit is contained in:
kapilvus 2026-06-22 23:51:47 +05:30
commit 6959b1b951

View file

@ -10,6 +10,7 @@ function josh_prompt {
prompt=" " prompt=" "
branch=$(git_current_branch) branch=$(git_current_branch)
branch="${branch//\%/%%}"
ruby_version=$(ruby_prompt_info) ruby_version=$(ruby_prompt_info)
path_size=${#PWD} path_size=${#PWD}
branch_size=${#branch} branch_size=${#branch}
@ -31,7 +32,7 @@ function josh_prompt {
prompt=" $prompt" prompt=" $prompt"
done done
prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(ruby_prompt_info)%{$reset_color%} ${branch//\%/%%}" prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(ruby_prompt_info)%{$reset_color%} ${branch}"
echo $prompt echo $prompt
} }