Here’s a situation: you’re watching a server log in Tmux, about to trigger an action that will produce log data you care about. You hit
return a bunch of times to create a visual break in the server log. Then you can scroll up and see the beginning of your revelant history.
What actually happens? Sometimes, the server logs tons and tons of information, and your visual break gets buried way above the fold. It’s hard to find the break, and you’re searching through all that information, plus anything that happened before.
There’s a better way! Tmux’s
clear-history command “removes and frees the history of the specified pane.” In the Hashrocket Dotmatrix, we combine that with
send keys -R, which “causes the terminal state to be reset.” Here’s the mapping:
bind-key C-k send-keys -R \; clear-history
Type the Tmux leader, then
C-k, and your terminal pane will be visually cleared and cleared of its history, making reading and reverse searching much easier.
h/t Gabe ReisTweet