diff --git a/agent-cmd.sh b/agent-cmd.sh index aded1e5..e40c5bd 100755 --- a/agent-cmd.sh +++ b/agent-cmd.sh @@ -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