Strange tmux status-bar rendering issues iterm2 - macos

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.

Related

I noticed that my terminals get a bit kooky after they forcibly disconnect from SSH

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.

tmux session preview not showing

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.

Is there a way to determine if a terminal is focused without asking the window manager?

I want to change some tmux styling when the terminal loses focus/becomes inactive (i.e. when I've clicked on an open Google Chrome window). I know I could check with the window manager to see which application window is focused, but this doesn't work across window managers.
Do terminal emulators themselves expose this information at all?
I tried running showkey -a to see if any escape sequence was sent when focus was lost, and it doesn't look like it.
I think some terminals implement this, but not all, based on this comment on the issue tracker for the vim-tmux-focus-events plugin:
About the question "I was expecting the event to fire when changing focus between different windows in my window manager": yea, I see how that would be very useful. I think this might be dependent on the terminal application you're using. I just tested this on OSX and here's some quick results:
it's working for iTerm when tmux is running inside the window
not working for iTerm running plain bash + vim inside (no tmux)
not working for Terminal.app (with or without tmux)
[...]
So, if I'm not wrong, it's up to terminal applications to implement "focus gained", "focus lost" functionality.
I have a vague memory (though I don't remember for sure) that focus gain/loss might have worked for me when using that plugin and gnome-terminal, so it might be worth a try.

Vim stops scrolling randomly in terminal?

Usually I can scroll in vim when I open a file in the mac terminal.
However, recently, all of a sudden sometimes I am not able to.
When I go to scroll, instead the entire terminal scrolls so I see what I had previously typed in the shell.
How can I fix this?
This is new, I've been using vim for months and it has only started to happen now.
You probably messed with the mouse setting.
:help mouse-using

PhpStorm terminal jumps from external monitor to default on focus, mac os x

I have 2 monitors: my notebook monitor, and primary big dell monitor. PhpStorm 9.02 and MacOS X 10.10.5.
When I work at PhpStorm, I move my terminal window to secondary notebook display, and when I focus PhpStorm or terminal, terminal jumps to primary monitor. When I work with 1 tab of terminal everything looks fine after switching on Pinned mode and Floating mode at terminal settings. But today I open 3 tabs, and terminal starts jumps again.
It's very annoying when you often switch between browser and PhpStorm.
Do somebody have the same problem and fix for it?
Known bug, please vote for IDEA-116096.
See also the corresponding JDK issue:
http://bugs.openjdk.java.net/browse/JDK-8069154
Please look #lena answer and vote for issue at intellij.
I found solution thats help me to avoid terminal window jumping:
Create new tabs in terminal.
Drag it to secondary display, so they become separate window.
Close main terminal window.
Child tabs don't jumps between displays.
I solved this by changing a setting in mission control.
Just uncheck the 'Displays have separate spaces' option.
Go to System Preferences.
Click on Mission Control.
Uncheck the box marked Displays have separate spaces.
Log out an login in again.

Resources