Fix fzf window size in agent-cmd.sh
This commit is contained in:
17
agent-cmd.sh
17
agent-cmd.sh
@@ -13,11 +13,22 @@ if [ ${#agents[@]} -eq 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
width=24
|
||||||
height=$((${#agents[@]} + 6))
|
height=$((${#agents[@]} + 6))
|
||||||
hmargin=$((($(tput cols) - width) / 2))
|
cols=$(tmux display-message -p '#{pane_width}')
|
||||||
vpad=$((($(tput lines) - height) / 2))
|
lines=$(tmux display-message -p '#{pane_height}')
|
||||||
|
hmargin=$(((cols - width) / 2))
|
||||||
|
vpad=$(((lines - height) / 2))
|
||||||
[ $hmargin -lt 0 ] && hmargin=0
|
[ $hmargin -lt 0 ] && hmargin=0
|
||||||
[ $vpad -lt 0 ] && vpad=0
|
[ $vpad -lt 0 ] && vpad=0
|
||||||
tput cup "$vpad" 0
|
tput cup "$vpad" 0
|
||||||
|
|||||||
Reference in New Issue
Block a user