tmux: Error-Monitoring Windows
Back to tmux (the terminal multiplexer) or see also tmux: Error-Monitoring Panes.
When doing Web development, in particular, I often want to monitor error logs while I’m using the thing I’m building to make sure I don’t miss any warnings or notices.
An unobtrusive way to do this with tmux is to follow the log in another tmux window and let it notify me visually when there’s activity.
First, I add a new window with the 'create' command:
Ctrl+B C
(Where Ctrl-B
is the default tmux command prefix.)
In that new window, I start "following" the log with tail
:
tail -f /var/www/logs/error.log
Then I like naming the window so I can see the name in the tmux status bar:
Ctrl-B , Log <Enter>
(That’s Ctrl-B
, followed by a comma (,
), followed by the name of the
window, then the Enter
key.)
Finally, and here’s the neat part, I turn on activity notifications for the window.
set -g monitor-activity on set -g visual-activity off
When there’s activity in the window, tmux prints a message in the status bar, changes the bar color, and highlights the "Log" window indicator in the status bar in "reverse video" style.
With this setup, I can program in another window and I know I won’t miss any log activity. Very handy.