Minimize fzf prompt size while centering it

This commit is contained in:
2026-05-13 15:52:36 +01:00
parent bcf2e92047
commit df23247b07

View File

@@ -13,11 +13,21 @@ if [ ${#agents[@]} -eq 0 ]; then
exit 1 exit 1
fi fi
# Minimize fzf prompt size while centering it.
width=24
height=$((${#agents[@]} + 6))
hmargin=$((($(tput cols) - width) / 2))
vpad=$((($(tput lines) - height) / 2))
[ $hmargin -lt 0 ] && hmargin=0
[ $vpad -lt 0 ] && vpad=0
tput cup "$vpad" 0
agent=$(printf '%s\n' "${agents[@]}" | fzf \ agent=$(printf '%s\n' "${agents[@]}" | fzf \
--prompt='agent> ' \ --prompt='agent> ' \
--reverse \ --reverse \
--border=rounded \ --border=rounded \
--margin=25%,30% \ --height="$height" \
--margin="0,$hmargin" \
--padding=1) --padding=1)
if [ -n "$agent" ]; then if [ -n "$agent" ]; then