The solution is to use tmux specific controls to access its own scrollback buffer: Ctrl-b then [ to enter copy mode, use Down/Up arrows or PageDown and PageUp keys, q or Enter to exit copy mode.
Ctrl + Alt + q Ask for confirmation before closing all tabs and killing the current tmux session. Browsers use Ctrl + Shift + w to close the current window and all its tabs and GNOME Terminal (which already uses Ctrl + Shift + w to close a single tab) uses Ctrl + Shift + q to close the whole window.
Press Ctrl + B keys followed by PgUp key. Now the terminal will go one page up directly in Tmux and check if this satisfies your requirements.
This same question has been plaguing me for quite some time. Here's the best I've come up with. Put this into your .tmux.conf file:
bind -n C-k clear-history
This binds ctrl-k to the tmux clear-history command. The -n after bind makes it so you don't have to issue the tmux command prefix (ctrl-b by default). I use bash, so ctrl-l already does the equivalent of typing "clear" at the command line. With these two keys I get a nice ctrl-l, ctrl-k combo, which moves all the scroll buffer off the screen (the "clear") and then deletes all that history (the tmux "clear-history" command).
It's not quite as nice as Terminal's, iTerm's, or Konsole's 1-key combos for clearing it out, but it's a world better than typing in clear-history all the time.
Every answer on here talks about adding new key bindings.
If you just want to do it occasionally you don't need a mapping at all...
Prefix defaults to <Ctrl-b>
Just type <prefix>
+ :
in the relevant pane and then type clear-history
and press enter.
If you are on the command line, you can run tmux clear-history
in the pane in question for the same effect.
One of the cool things about tmux is that you can just run any of the commands like that... or run them in a shell/script them like tmux command
... or make a keyboard shortcut for them.
As @juanpaco correctly stated, clear-history
is the command to clear the scrollback buffer.
I'll add that I like to also clear what's on the screen in the same command.
Issuing a send-keys -R
resets (clears) the screen, so I use the following in my .tmux.conf
bind-key b send-keys -R \; clear-history
This clears the screen AND the scrollback buffer.
If you want to combine CTRL-L
plus clear-history, add this to your ~/.tmux.conf
:
bind u send-keys C-l \; run-shell "sleep .3s" \; clear-history
This even works if you're in a MySQL shell for instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With