How to fix a tmux session messed up by control characters
Solution 1
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.
Solution 2
3 options...
stty sane
reset
-
echo ^v^o
(that's E
Solution 3
Ctrl+B then r should do it. This causes tmux to redraw the entire screen from scratch.
Solution 4
ctrl-b r is not the right answer. The right answer is:
ctrl-b shift-D
to get a list of the attached sessions- 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)
- 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.
Server Fault
Updated on September 18, 2022Comments
-
Server Fault over 1 year
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 over 5 yearsGood idea, but no luck.
-
Michael Hampton over 5 yearsHuh. 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?
-
Server Fault over 5 yearsHrm.. I am using xfce4-terminal. Maybe that's the problem. If you don't mind, try
gpg --export
. That usually does it. -
Michael Hampton over 5 yearsTried
gpg --export
. GNOME terminal 3.30 just laughs it off, in or out of tmux. -
Server Fault over 5 yearsLikely 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 over 5 yearsI'm just going to accept this as the answer because in typical circumstances,
ctrl+b r
is how to do it -
Michael Hampton over 5 yearsI 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?
-
Server Fault over 5 yearsUpgrade 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 over 5 yearsCan't seem to get this to work either. When I
tmux attach -t 0
the session is still corrupt from thegpg --export
output -
Server Fault over 5 yearsThanks, this works!
stty sane; printf '\033k%s\033\\\033]2;%s\007' "
basename "$SHELL"" "
uname -n"; tput reset; tmux refresh