- # Display current directory on the left in the top prompt. Truncate the
- # directory if necessary.
- width=$(( COLUMNS - 4 - 1 - width_right ))
- top_left=".-$default%b($yellow%$width<..<%~%<<$default)%B$blue"
+ # Number of background processes in yellow.
+ local background="%(1j.${yellow}%j${default}.)"
+ # Exit code in bright red if not zero.
+ local exitcode="%(?..(${red}%B%?%b${default}%) )"
+
+ # Prefix characters in first and second line.
+ local top_prefix="${blue}%B.-%b${default}"
+ local bottom_prefix="${blue}%B'%b${default}"
+
+ # Combine them to create the prompt.
+
+ local top_right="${vcs}(${seconds})"
+
+ local width_top_prefix=${#${(S%%)top_prefix//$~zero/}}
+ local width_top_right=${#${(S%%)top_right//$~zero/}}
+
+ # Calculate the maximum width of ${top_left}. -2 are the braces of
+ # ${top_left}, -1 is one separator from ${top_separator} (we want at least
+ # one between left and right parts).
+ local top_left_width_max=$((
+ COLUMNS - $width_top_prefix - 2 - 1 - $width_top_right
+ ))
+ # Truncate directory if necessary.
+ local top_left="(${directory/WIDTH/${top_left_width_max}})"
+ local width_top_left=${#${(S%%)top_left//$~zero/}}