hide items in tmux statusline width for thinner viewport

This commit is contained in:
David Chen 2025-09-22 10:04:58 -07:00
parent 61ace2ef02
commit 9b9ed00ee2
2 changed files with 57 additions and 1 deletions

View file

@ -1,6 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
# hide entire right status if terminal width is below threshold
min_width=${TMUX_RIGHT_MIN_WIDTH:-90}
width=$(tmux display-message -p '#{client_width}' 2>/dev/null || true)
if [[ -z "${width:-}" || "$width" == "0" ]]; then
width=$(tmux display-message -p '#{window_width}' 2>/dev/null || true)
fi
if [[ -z "${width:-}" || "$width" == "0" ]]; then
width=${COLUMNS:-}
fi
if [[ -n "${width:-}" && "$width" =~ ^[0-9]+$ ]]; then
if (( width < min_width )); then
exit 0
fi
fi
status_bg=$(tmux show -gqv status-bg)
if [[ -z "$status_bg" || "$status_bg" == "default" ]]; then
status_bg=black