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

1 Answer 1

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .