diff options
Diffstat (limited to 'etc')
| -rwxr-xr-x | etc/tmux/continuum-throttle.sh | 19 | ||||
| -rw-r--r-- | etc/tmux/tmux.conf | 6 |
2 files changed, 25 insertions, 0 deletions
diff --git a/etc/tmux/continuum-throttle.sh b/etc/tmux/continuum-throttle.sh new file mode 100755 index 00000000..e0e3dabb --- /dev/null +++ b/etc/tmux/continuum-throttle.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Throttle wrapper around tmux-continuum's save script. +# +# tmux re-renders status-right per client per status-interval, so the +# upstream save script is invoked far more often than it can possibly do +# useful work. This wrapper short-circuits the common case using only +# bash builtins (no fork, no subprocess) and only execs the real script +# when the throttle window has elapsed. + +throttle=60 +stamp="${XDG_RUNTIME_DIR:-/tmp}/tmux-continuum-throttle.stamp" +real=~/.guix-home/profile/share/tmux-plugins/continuum/scripts/continuum_save.sh + +last=0 +[[ -r $stamp ]] && read -r last < "$stamp" +(( EPOCHSECONDS - last < throttle )) && exit 0 + +printf '%s\n' "$EPOCHSECONDS" > "$stamp" +exec "$real" diff --git a/etc/tmux/tmux.conf b/etc/tmux/tmux.conf index 53fee2b3..562edc0a 100644 --- a/etc/tmux/tmux.conf +++ b/etc/tmux/tmux.conf @@ -98,3 +98,9 @@ set -g @resurrect-capture-pane-contents 'on' set -g @resurrect-processes '~make ~ssh ~e "~alot->alot" "~ranger->ranger" "~newsboat->newsboat" "~entr->entr" "~git->git" "~info->info"' run-shell ~/.guix-home/profile/share/tmux-plugins/resurrect/resurrect.tmux run-shell ~/.guix-home/profile/share/tmux-plugins/continuum/continuum.tmux + +# Throttle continuum's status-right hook to avoid per-client per-tick fork +# storms (the upstream save script forks bash + several `tmux show-option` +# subprocesses every invocation). The wrapper short-circuits in pure bash. +set -g status-interval 60 +set -g status-right "#(~/.usr/etc/tmux/continuum-throttle.sh)" |
