I tried using tmux with iTerm2 recently and it works perfectly for about one minute after I attach using the command via iTerm:
$ tmux -CC attach
However one minute after attaching, on the very next keystroke it detaches, as if it somehow timed out. This happens whether or not I do anything in the tmux window. The session is still there and I can reattach with no problems, but of course it disconnects again after a minute. I don't have this issue when using screen or when using tmux without the iTerm integration. Has anyone had a similar issue or know why iTerm may be detaching?
Figured it out! iTerm has the following feature:
"When idle, send ASCII code 0" (by default) Since I don't interact with the tmux control window, it sends the null ASCII code after one minute, which appears to cleanly detach the session. It doesn't matter what I do in the tmux windows, whether they are idle or not.
So glad to have worked this out. Not sure why I had this enabled, as I don't think I need it. It explains some other odd issues I have noticed once or twice (randomly pasting in vim, etc)
Goodbye, screen!
Related
The terminal begins to behave a little bit strangely after an SSH session inside has been terminated (due to sleeping the computer or killing it via <Enter>+~+.).
It causes a beep to be emitted whenever focus enters and leaves the particular terminal. Also when in my zsh shell, a blank new line appears to be fed into the terminal.
I've tested this in:
tmux in alacritty
raw alacritty
iTerm2
This is not a hugely annoying behavior, although the bell is definitely annoying for sure.
Today I was able to finally find a way to reproduce the behavior. Clearly this is somehow related to a terminal mode that SSH puts the terminal into and which it fails to clean up when it dies. But it is also related to the focus reporting.
I have tried stty sane but it does not work. Not even starting and quitting vim works. That usually is able to reset various other terminal state weirdnesses, such as being stuck in mouse mode where clicking the mouse on the terminal (and especially scrolling your mouse) produces lots of bells.
Inspired by the answer https://superuser.com/a/1017817/98199, I found that issuing the command echo '\x1b[?1004l' does effectively turn off the focus reporting, and restores normal behavior.
Since vim definitely is capable of recognizing focus events I do not know why starting and stopping vim does not do the trick for this. I suppose I will make this command into an alias and just run it when I need to.
I'm running into this strange issue with my tmux in iterm where it appears to be rendering on the wrong line, but this causes strange rendering issues to happen
Here is the basic behavior:
You'll notice the menubar is offset by one line. This is fine, for the most part, except when I start entering tmux commands I get behavior like this:
I've also noticed that sometimes the menu bar will entirely disappear and I won't be able to show which sessions i have open. I've also noticed that sometimes if I select the text in my terminal with my mouse, it will select text one-line up from what I expected to select.
I've tried a bunch of things to debug this, including:
re-install tmux
clear tmux-resurrect history
restart my computer
reinstall iterm
resizing the iterm window (both manually, and using cmd+ and cmd, which I have a theory was what triggered this behavior)
I've also noticed that if I run tmux in the default terminal macOS application it behaves normally with no issues.
Does anyone have any ideas of things I could try?
I have unchecked all of these options, and the strange behavior disappears.
I am using tmux in a number of machines. I have a weird behavior and I cannot find the reason.
I have a laptop running tmux 3.0a and when I do prefix s I get the following:
i.e. a preview of the highlighted session
My desktop machine with tmux 3.0a as well has no preview (I have updated to 3.1b but still nothing):
Both machines have the same tmux.conf
Any ideas?
EDIT: Toggle preview: v is not working on my desktop. If I press it the only thing that happens is that the cursor disappears until I move the mouse again.
Are you sure you are using 3.0a? Check tmux display -p '#{version}'. Remember you need to restart tmux entirely (tmux kill-server) after upgrading.
When i re-attach to an existing/running window, the screen doesn't seem to be responding.
I can key in the input but no output displayed on the screen. When i do screen -ls, the screen and the socket is still there.
Anyone has any idea what could have probably happened prior to this? I could only restore the functionality by rebooting the server. Not sure if something has been broken between the screen and shell due to bad characters.
I've seen this happen -- typically when I foolishly suspended output to my terminal (like when I fat finger and hit CTRL-S or some other nonsense). We leave quite a few processes running in screen, so it's always a panic moment when we get a hung screen session.
The solution is to identify the sshd session associated with screen, and kill it. This will free the screen and allow you to re-attach from another ssh session. (note: be careful to NOT kill the main sshd or you may not be able to login remotely).
I find pstree -ac invaluable in these situations.
If the command that you run for the screen will terminate soon, the screen will show as blank and not show the output.
But if you run command like top python3 -m http.server nano * that will not terminate soon, the screen will show.
EDIT
To solve this problem, you can run exec echo "hello world" after create screen.
I'm trying to debug why tmux processes still think they're attached when I close the terminal they live inside of, and I think I've discovered part of the problem; when I close a terminal window (CMD-W or clicking the little red button in the top left) it doesn't send SIGHUP! In fact, it only sends SIGEXIT. I discovered this using the script from this SO question. One of the posters gave a very different result from his OSX machine, however my terminal does not seem to want to play nicely.
Does anyone know how to make the terminal in OSX (I'm running 10.7.2) send the proper signals when exiting? Thanks!