foxshell/fn/-z4h-prompt-length
2025-07-04 11:48:40 -05:00

15 lines
288 B
Bash

#!/usr/bin/env zsh
local -i COLUMNS=1024
local -i x y=${#1} m
if (( y )); then
while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do
x=y
(( y *= 2 ))
done
while (( y > x + 1 )); do
(( m = x + (y - x) / 2 ))
(( ${${(%):-$1%$m(l.x.y)}[-1]} = m ))
done
fi
typeset -g REPLY=$x