1

I want to "clear" the tmux pane completely. When I do something like

bind-key C send-keys "clear && tmux clear-history" \; send-keys "Enter" 

suggested in https://stackoverflow.com/questions/10543684/how-can-i-clear-scrollback-buffer-in-tmux, I am able to clear the scrollback buffer and get a clean screen.

However when I do Shift+PageUp and Shift+PageDown I am able to see the previous output from the terminal emulator itself (not tmux). Normally you can do reset command to clear the scrollback history of the terminal emulator.

Is it possible to reset the Terminal Emulator from tmux? Along with the above scrollback clear?

Couple of workaround suggested are:

1) To keep Urxvt.saveLines: 0 or start Urxvt -sl 0 - This is logical since you don't need Terminal Emulator's scrollback if you are in tmux.

2) Detach, reset and re-attach tmux - This seems cumbersome.

1

What you want is printf "\033c" > $client_tty, where $client_tty is the TTY that the tmux client is running on. \033c is the escape sequence for the ANSI reset command.

You can list all connected clients with their TTYs with tmux list-clients. Limit it to a specific session with -t $session_name, and to outputting only the TTY with -F '#{client_tty}'. Thus, to reset all connected tmux clients, you want something like:

for client_tty in $(tmux list-clients -F '#{client_tty}'); do
    printf "\033c" > $client_tty
done

You will also want to issue tmux refresh on all clients you've reset this way to restore tmux to its usual state.

  • I just didn't understand this back then! – Nishant Dec 27 '16 at 6:30
  • 1
    To be fair, I probably could have explained it better now than then. Regardless, happy to be of service! – Celti Dec 28 '16 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.