Fix fzf window size in agent-cmd.sh

This commit is contained in:
2026-08-03 12:02:32 +01:00
parent 6d62df2d7e
commit 6f9d5a6693

View File

@@ -13,11 +13,22 @@ if [ ${#agents[@]} -eq 0 ]; then
exit 1
fi
# Minimize fzf prompt size while centering it.
# This runs as the window's default-command, which tmux starts *before* the
# popup client attaches. Until then the pane keeps a stale default size (often
# 80x24), so wait for the attach before measuring — otherwise fzf is sized
# against the wrong dimensions and renders far too small.
for _ in $(seq 1 100); do
[ "$(tmux display-message -p '#{session_attached}')" -gt 0 ] && break
sleep 0.02
done
# Minimize fzf prompt size while centering it, using the real pane dimensions.
width=24
height=$((${#agents[@]} + 6))
hmargin=$((($(tput cols) - width) / 2))
vpad=$((($(tput lines) - height) / 2))
cols=$(tmux display-message -p '#{pane_width}')
lines=$(tmux display-message -p '#{pane_height}')
hmargin=$(((cols - width) / 2))
vpad=$(((lines - height) / 2))
[ $hmargin -lt 0 ] && hmargin=0
[ $vpad -lt 0 ] && vpad=0
tput cup "$vpad" 0