5

Every once in awhile, I'll accidentally blast some control codes into my terminal session (either errant coding or accidentally gpg --export). This sometimes causes my tmux session to loose it's formatting and print control characters into the borders of the tmux windows. All the tmux windows get pretty messed up after than. Even just focusing a window messes up the other windows. The traditional reset tricks for a terminal (reset, echo [CTRL]+V [CTRL]+C) don't fix it so I end up logging out of all active sessions and having to restart tmux.

Anyone know of a way to reset/refresh all the tmux panes without terminating tmux ?

Server Fault
  • 3,454
  • 7
  • 48
  • 88

4 Answers4

5

Ctrl+B then r should do it. This causes tmux to redraw the entire screen from scratch.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • Good idea, but no luck. – Server Fault Nov 30 '18 at 19:44
  • Huh. You know, I can't even _get_ my GNOME terminal with tmux to go haywire like that anymore, not even by deliberately catting binary files to it. Maybe it's time for some upgrades? – Michael Hampton Nov 30 '18 at 19:46
  • Hrm.. I am using xfce4-terminal. Maybe that's the problem. If you don't mind, try `gpg --export`. That usually does it. – Server Fault Nov 30 '18 at 19:59
  • Tried `gpg --export`. GNOME terminal 3.30 just laughs it off, in or out of tmux. – Michael Hampton Nov 30 '18 at 20:01
  • Likely something with my setup or tmux verson. I'm running Ubuntu 16.04 and this happens with xterm, LXterminal and xfce4-terminal. I'll see if I can root it out. Thanks for your time. – Server Fault Nov 30 '18 at 20:06
  • I'm just going to accept this as the answer because in typical circumstances, `ctrl+b r` is how to do it – Server Fault Nov 30 '18 at 21:06
  • I do know what you're talking about though, I just can't recall experiencing it in a few years. I do run Fedora as my workstation though, so I'm usually on the latest or nearly latest code. Maybe it's time to upgrade? – Michael Hampton Nov 30 '18 at 21:07
  • Upgrade may fix it. I usually run my workstation on the same OS our servers run so kind of married to 16.04 at the moment. – Server Fault Nov 30 '18 at 21:17
4

3 options...

  1. stty sane
  2. reset
  3. echo ^v^o (that's E
John L
  • 41
  • 1
3

There is a detailed explication how to reset many parts of tmux in stack exchange: https://unix.stackexchange.com/questions/49886/tmux-status-bar-corrupted-after-catting-a-binary-file-how-to-reset

For me, often only tmux rename-window myWindowName and printf '\033]2;%s\007' "$(uname -n) (set status right) are required.

simohe
  • 216
  • 2
  • 5
  • Thanks, this works! `stty sane; printf '\033k%s\033\\\033]2;%s\007' "`basename "$SHELL"`" "`uname -n`"; tput reset; tmux refresh` – Server Fault Jan 17 '19 at 19:15
2

ctrl-b r is not the right answer. The right answer is:

  1. ctrl-b shift-D to get a list of the attached sessions
  2. select the session that you were using when you messed up the screen, and press Enter to detach it (or iterate through this list and detach from all sessions, if you prefer)
  3. if detached from all sessions in #2, then tmux attach -t again to attach a brand new session. This will get rid of the problematic session without having to terminate tmux.
Michael Martinez
  • 2,543
  • 3
  • 20
  • 31
  • Can't seem to get this to work either. When I `tmux attach -t 0` the session is still corrupt from the `gpg --export` output – Server Fault Jan 17 '19 at 19:12