Navigate Long Logs in Tmux Copy Mode
Use tmux scrollback to find a marked line in synthetic output and return to the live shell without interrupting it.
Difficulty Beginner
Prerequisites
Use an installed tmux and a temporary session. The exercise uses the default Ctrl+B prefix and the emacs copy-mode key table. Start a named practice session from a terminal outside tmux.
Create searchable output
tmux new-session -s log-practice
In the session's pane, generate 120 test messages with one marker.
for number in $(seq 1 120); do
if [ "$number" -eq 42 ]; then
printf '%s\n' "event $number CHECKPOINT"
else
printf '%s\n' "event $number"
fi
done
Press Ctrl+B then [ to enter copy mode. Use Page Up to move through history or Ctrl+R to search backward in the emacs key table. Search for CHECKPOINT to find line 42. Press q to exit copy mode. The shell remains available.
Troubleshooting and practice
If Ctrl+R appears to start shell history search, confirm that you entered tmux copy mode first. Inspect tmux show-options -w -v mode-keys. The vi table uses ? for backward search. If older output is missing, scrollback may have reached the history limit. Check tmux show-options -g history-limit and set a suitable value before creating future practice panes. Add two more synthetic markers and try locating them in reverse chronological order. Avoid copying real logs containing identifiers or credentials into public channels.