Dynamic tmux popup sizing across different displays
tmux's display-popup is hard to size when you switch between displays. Fixed
character sizes are either too small on 4K or too large on a laptop. Percentages
don't help either - 60% of a 4K monitor is massive.
With some help, came up with a wrapper script that uses a fancy algorithm.
popup = base × (screen / reference) ^ 0.5
You set your reference screen (the one you tune on) and base sizes for each preset. On other screens, sizes scale sub-linearly - a screen twice as large gets a popup ~1.4x bigger, not 2x.
#!/usr/bin/env bash
# Reference screen (MacBook) - presets are tuned for this size
REF_W=186
REF_H=43
# Scaling factor (0.0-1.0): lower = more "sticky", higher = more linear
SCALE=0.5
# Size presets: base_w, max_w, base_h, max_h
size="medium"
while ; do
done
if ; then
fi
Usage in .tmux.conf:
bind C-j run-shell 'tmux-popup --size medium workmux'
bind C-f run-shell 'tmux-popup workmux'
To tune, first get your terminal size with
tmux display -p '#{window_width} #{window_height}', set REF_W/REF_H to
match, then adjust the base values until they look right. The SCALE factor
controls how much sizes grow on larger screens.
Will keep experimenting with this but for now it feels good.