tmux-plugins / tmux-sensible

basic tmux settings everyone can agree on
MIT License
1.76k stars 91 forks source link

Tmux integration with iTerm didn't working with `setw -g aggressive-resize on` #24

Closed iAdramelk closed 3 years ago

iAdramelk commented 9 years ago

iTerm is Terminal alternative form Mac OS X. It has from the box integration with tmux: https://gitlab.com/gnachman/iterm2/wikis/TmuxIntegration

Then you try to reattach to session in iTerm while using tmux-sensible it didn't work because of the tmux-sensible. It just shows message: «The "aggressive-resize" option is turned on in tmux. It is not compatible with the iTerm2-tmux integration. Please disable it and try again.» and exits.

m1foley commented 9 years ago

I'm able to reproduce this: when I ran tmux -CC in iTerm 2.1.1, it gave me that warning and exited. It worked when I added setw -g aggressive-resize off to my .tmux.conf.

I'd assume there's enough Mac users using iTerm integration mode to question whether aggressive-resize is in the "options that should be acceptable to everyone".

bruno- commented 9 years ago

Hey guys, first of all, thanks for reporting. Yea this definitely doesn't look too sensible at first sight.

I updated iterm to the latest version 2.1.1 and indeed, when ran with tmux -CC I get the message about aggressive-resize being unsupported.

A quick solution to the problem would be to test if user's terminal is iterm: [[ "$TERM_PROGRAM" =~ ^iTerm ]]. Based on that, we can skip setting aggressive-resize 'on'. Ideally, we would also wanna check if tmux is ran in CONTROL MODE - do you know if we can get this info somehow?

On the other hand I was playing with iterm-tmux integration mode and man - it's very very very limited. Does any one of you actually use this?

I also tested running "regular" tmux (no control mode) in iterm and everything works just fine with it.

iAdramelk commented 9 years ago

Hi, Bruno!

Yes, I'm using tmux+iTerm integration on practice. But I'm mostly use it for local development, so I'm not very representative.

Unfortunately I don't know how to check for CONTROL MODE.

bruno- commented 9 years ago

Hey, thanks for the prompt response.

Give me some time to try to figure control mode detection. If nothing, we'll fallback to just checking iterm as aggressive-resize is not that important option.

bruno- commented 9 years ago

This issue should now be fixed on iterm2. Just pull the latest tmux-sensible and let me know if all is ok?

I asked on #tmux irc group and the tmux maintainer (Thomas) said detecting control mode is currently not possible. This means aggressive-resize will be off when using tmux old-school way (no special integration mode).

On the up side, implementing the control mode detection was easy so Thomas just made a patch. Suggestion to merge this to tmux core is here.

If this is merged, then a test for checking if control mode is used will be something like this [ "$(tmux display -p -F "#{client_control_flag}")" != "0" ]. Let's leave the issue open till we see what happens with the patch.

m1foley commented 9 years ago

To answer your question: I use tmux + iTerm professionally, and I've seen other developers doing so as well, and this is the first time I've heard of iTerm integration mode. Given the limitations of the feature, I'm guessing it's for developers who want to occassionally use tmux to pair program, but are too intimidated/lazy to learn tmux commands.

The proposed fix will inconvenience me, but I don't know if we have much of a choice: I'd guess that most developers on Macs use iTerm as their terminal, so even if a small percentage of them use integration mode that's still a lot of people.

bruno- commented 9 years ago

Thanks for the sharing the details @m1foley.

The proposed fix will inconvenience me

Can you explain this a little bit? From what I know aggressive-resize on is useful with a multi-monitor setup when each screen has it's own terminal attached to the same tmux server. You have this setup?

m1foley commented 9 years ago

Now that I've read the documentation, I was wrong about that -- I don't use aggressive-resize on.

neumachen commented 9 years ago

So is this supported? I do have a multi monitor setup and it would be the bomb if this was working with iterm2 since I have a script that opens a bunch of tmux sessions within VM's or remote servers.

neumachen commented 9 years ago

Any news onm this front? Would love to know if this will be a feature released soon. Perhaps I can help out if this is in the back burner.

bruno- commented 8 years ago

Hey @magicalbanana, this is not really a feature, just a tmux option we thought was sensible, but it turns out there were problems with it.

If you're NOT using iterm this is already working for you. If you ARE using iterm (but not its control mode) then just add set-window-option -g aggressive-resize on to .tmux.conf and that's it.

neumachen commented 8 years ago

@bruno- yeah. I am familiar that it works with iterm2. What I thought would be possible was having that active AND be in control mode, because when that's active that's when it doesn't work.

bruno- commented 8 years ago

Ah, ok. I'm not sure when or IF this will be fixed. It depends solely on iterm2 and tmux core developers, maybe you wanna check with them?

Another solution would be to switch from iterm-tmux integration to "regular" tmux mode. Last time I checked iterm-tmux integration mode was very limited. Regular tmux has much more powerful set of features.

neumachen commented 8 years ago

How do you do regular tmux with iterm2?

bruno- commented 8 years ago

This thread assumes you're starting tmux in control mode with: tmux -C under iterm.

"Regular tmux" usage assumes using just the tmux command.

neohunter commented 8 years ago

with tmux 2.1 I'm having this problem even when adding setw -g aggressive-resize off

eapolinario commented 8 years ago

was this ever resolved? I'm running iTerm 2.1.4 and tmux 2.1 and still seeing this.

nonzer0 commented 8 years ago

@eapolinario if you're using prezto and like me and haven't updated in a while do a git pull. That fixed things for me.

gukoff commented 8 years ago

Tmux 2.3.0, the issue is still there after installing the Tmux Plugin Manager. Fixed it by adding setw -g aggressive-resize off to the very last line in tmux.conf at the remote machine and running tmux source ~/.tmux.conf in the tmux window afterwards.

~/.tmux.conf

# Tmux plugin manager
set -g @plugin 'tmux-plugins/tpm'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

# Fixes iterm2 integration. Should go after "run '~/.tmux/plugins/tpm/tpm'"
setw -g aggressive-resize off
jesse-c commented 5 years ago

Even with @gukoff's approach, I'm still seeing the complain.

tmux: 2.9a iTerm2: 3.3.3

I've changed my tmux config to only have setw -g aggressive-resize off and I'm still seeing the error.

jxchong commented 4 years ago

I am also having this issue despite the last line of my .tmux.conf file being setw -g aggressive-resize off and reloading the file

I exclusively use iterm+tmux integration because I am not a hardcore developer but analyze scientific data on the cluster all the time. I recommend to everyone I know to use iterm2+tmux because basic usage is dead simple (you can create new tmux windows, sessions, and tabs with standard Mac keyboard shortcuts or even right click menus). Most of the time, I see people just creating a ton of new Terminal windows/connections instead, or using nohup(!)

jxchong commented 4 years ago

I am also having this issue despite the last line of my .tmux.conf file being setw -g aggressive-resize off and reloading the file

If I kill the tmux server (2.9a) and start a brand new session, everything is fine. As soon as I detach from that session and try to reattach to it tmux -CC attach -t 0, I get the error about aggressive-resize being on.

My console shows:

[jxchong@grchead ~]$ tmux -CC attach -t 'New Session'
** tmux mode started **

Command Menu
----------------------------
esc    Detach cleanly.
  X    Force-quit tmux mode.
  L    Toggle logging.
  C    Run tmux command.
Detached
%begin 1581469179 893 1
%end 1581469179 893 1
%exit
foeken commented 4 years ago

Seems the best fix for this is to set your TERM_PROGRAM Env variable if you are coming across this issue on an SSH session. Either do it manually, or send it along your ssh connection with SendEnv (the server needs to allow the variable though, by default it doesn't).

This fixed it for me :)

Ps. A proper fix would be for tmux-sensible to also listen to LC_TERMINAL (which iTerm automatically sends over ssh)

avatar-lavventura commented 4 years ago

When the panel splitted vertically if there is a panel tab bar, the window decreases the height of the panel bar @jesse-c

prash1981 commented 2 years ago

I still see this issue.

tmux - 3.2a iterm - 3.4.15

I had to kill the server and recreate the sessions. I have continuum and resurrect plugins which i enabled recently and this issue seems to happen only when my server reboots (which happens once a month). Not sure if the plugins are not compatible with sensible for some reason.

I have tried all the workarounds mentioned in this thread, without success.

tcapelle commented 2 years ago

Same issue here on latest iTerm2 and tmux.

sinewalker commented 2 months ago

... and same in vscode. I tried this hack, but could not make it work. I'll make a new issue

iterm_terminal() {
    [[ "${TERM_PROGRAM}" =~ ^iTerm || "${LC_TERMINAL}" =~ ^iTerm || "${TERM_PROGRAM}" =~ ^vscode ]]
}

For now, I'm just commenting out the call to set-window-option -g aggressive-resize on on line 124

UPDATE MJL20240730: created https://github.com/tmux-plugins/tmux-sensible/issues/73