tmux capture-pane -p only reads visible screen, silently missing scrolled-off output
A common tmux monitoring pattern using 'capture-pane -p' only captures the currently visible pane, which is typically 24 to 50 lines tall, leaving any scrolled-off output invisible to grep checks. This causes silent false negatives in production — tmux returns exit code zero and no error, even when the target string has scrolled off screen. The bug is intermittent, passing reliably in quiet tests but failing under real load when output keeps streaming. The fix is adding the '-S' flag, such as '-S -3000', which instructs tmux to start the capture from within the scrollback buffer rather than the visible screen only. Using a bounded value like '-S -3000' is recommended over the unbounded '-S -' to avoid pulling multi-megabyte captures from chatty processes on every poll.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in