Different-sized windows in tmux session

3,055 views
Skip to first unread message

Daniel Roseman

unread,
Jan 27, 2012, 5:26:19 AM1/27/12
to iterm2-...@googlegroups.com
First of all, thanks for the fantastic tmux integration - it's incredibly helpful, really made things a lot nicer.

Here's my issue. I like to work with one iTerm2 window with a series of tabs for various command shells, and a separate large window for a vim session. These are both ssh-ed into the same server, so it would be useful to have them both running through tmux. However, it doesn't seem to be possible to have two different-sized windows attached to one tmux session - even though they're separate windows rather than tabs, resizing one automatically resizes the other.

Why does this happen, and is there any way of turning it off? Presumably an alternative would be to have two tmux sessions running simultaneously, but as noted elsewhere this isn't yet possible. Any advice?

Thanks,
Daniel.

Scott Gifford

unread,
Jan 30, 2012, 12:29:20 PM1/30/12
to iterm2-...@googlegroups.com
On Fri, Jan 27, 2012 at 5:26 AM, Daniel Roseman <dan...@roseman.org.uk> wrote:
[ ... ]
it doesn't seem to be possible to have two different-sized windows attached to one tmux session - even though they're separate windows rather than tabs, resizing one automatically resizes the other.

I have noticed this too, and thought it was a bug.  Is this resizing behavior intentional?  If not, let me know if you need help reproducing it, I see it pretty often.

-----Scott.

George Nachman

unread,
Jan 30, 2012, 1:48:12 PM1/30/12
to iterm2-...@googlegroups.com
Tmux doesn't allow different sized windows in a session. Remember that
the integration remains compatible with "normal" tmux operation.
Another client could be connected to the same tmux session through the
traditional UI where all windows are multiplexed onto a single
display, and they must all fit. This assumption is baked deep into
tmux.

This restriction could be relaxed by allowing multiple sessions to be
in use through one client. This wouldn't happen in time for 2.0
though.

regnauld

unread,
Feb 9, 2012, 2:36:06 PM2/9/12
to iterm2-discuss


On Jan 30, 7:48 pm, George Nachman <gnach...@llamas.org> wrote:
> Tmux doesn't allow different sized windows in a session. Remember that
> the integration remains compatible with "normal" tmux operation.

Fair enough, but I also noticed that using CMD-+ and CMD- - to change
the font size also changes the font size on every window...
Technically the terminal size is not changing, but the font size (and
consequently *window* size) is changed for *all* tmux windows.

George Nachman

unread,
Feb 9, 2012, 9:23:11 PM2/9/12
to iterm2-...@googlegroups.com
If you joined sessions together in the same tab, they'd have to have
the same font size or else there would be huge gaps of empty space for
the layout to be compatible with a "traditional" tmux client. Same
thing if two tmux tabs in the same window had different font sizes. In
the name of simplicity, I forced them all to have the same font size.
This can be relaxed when multiple sessions are supported.

Mike Schwartz

unread,
Mar 28, 2016, 12:54:23 PM3/28/16
to iterm2-discuss
I've used screen quite a bit and the concepts of tmux are not hard to fathom.

However, I agree that what I WANT iTerm2 to do is to allow me to ssh in to a server, open 5 windows with command-N, resize and position them, run programs in them, etc.  When I suspend and attach, I want my windows to open up at the same positions and with the same program states in each.

Granted you have to do what tmux allows.

It does allow you to split panes, etc.  So why not link iTerm2 windows to panes on the one tmux connection?  When I resize a window, you resize a pane on the host appropriately.

Call it a special mode, if you like.  When in this mode (via menu, whatnot), it makes no sense to attach to the session via some other means or for some other purpose (paired viewing, for example).

It seems to me you can inject commands into a terminal at the prompt and intercept and parse the output of those commands.  Keep my window positions in a .iterm2-tmuxrc file and cat that on attach.

You can store all kinds of info in that rc file, too.  Enough that when shell integration tells you a session has started, you grab the rc contents and can add menus to attach to tmux session, attach to tmux session "window" (panes) individually, etc.

I realize I can make a .sh script that opens windows at the right positions and ssh into the host and attach to one of the several tmux sessions to achieve what I want.  But the point is to make iTerm2 multiplex the multiplexer :)

George Nachman

unread,
Mar 28, 2016, 4:29:15 PM3/28/16
to iterm2-discuss
1. I want different sized windows.

Tmux does not allow windows to have different sizes (except for the aggressive-resize option, which merely postpones the resizing), as you note.

2. Why not link iTerm2 windows to panes on one tmux connection?

Because this leads to madness. tmux window panes must completely tile the window the belong to, so you'd end up with silly extra window panes you don't want. Even if you devised a way to hide them, it's an impedance mismatch with how tmux works that would cause endless bugs and headaches. It's better to relax the restriction on the tmux side.



--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Schwartz

unread,
Mar 28, 2016, 5:25:53 PM3/28/16
to iterm2-...@googlegroups.com
Thanks for the explanation.

Hard things should be overcome, IMO.  It’s up to you.  I’d be happy with silly extra panes - hence the suggestion for the special tmux mode in my post.  You might even make “tmux mode” a checkbox in the profile settings.

As is, I see a lot of promise in tmux integration.  Something to mux the mux-er.  As it is, I don’t see a whole lot of advantage over just running tmux in multiple iTerm2 windows.  Or screen.


You received this message because you are subscribed to a topic in the Google Groups "iterm2-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/iterm2-discuss/Etfozb_63Pg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to iterm2-discus...@googlegroups.com.

George Nachman

unread,
Mar 29, 2016, 12:39:39 PM3/29/16
to iterm2-discuss
I agree that it's a problem worth solving, but I think the solution is to make tmux more flexible. I haven't got the bandwidth to do this right now, but it's something I'm interested in doing eventually (and it's certainly an area that's ripe for someone with some C skills to help on).

As for why you'd use tmux integration instead of native tmux, it would be because you prefer native windows and UI interactions over tmux's UI. It's not for everyone, and that's fine.

Mike Schwartz

unread,
Mar 29, 2016, 12:49:46 PM3/29/16
to iterm2-...@googlegroups.com
Appreciate the sentiment.

My vision of integration is something like this:

1) Start a tmux session - this is distinct from a regular iTerm2 session.
2) A window opens
3) I can resize the window at will
4) If I command-N to open a new window, it is also a tmux window
5) The second window is resizable separate from the 1st
6) new tabs in the window are tmux also.
7) you can drag new tabs to desktop to create a standalone window, resizable, etc.
8) commands for tmux are on the menus and become active (e.g. detach)
9) close a window, it kills the tmux window (pane, whatever)
10) suspend tmux (via menu, hot key) closes all windows for the specified server

You have shell integration and password feature.  I could see you using that:

1) If you tmux login 1st window, you can automagically ssh in to the same server (on command-N, etc.) using the password.
2) On the server, you can keep a tmuxrc file and send that to the mac side on login
3) tmuxrc can contain window count/names, position, size, and whatever other info that enhances the user experience.
4) You do this because I want to use the tmuxrc on many hosts, my iMac at work, my macbook at home.

I don’t mean to seem harsh about this criticism/suggestion.  Use it as you will.

David Rees

unread,
Dec 21, 2017, 9:27:25 PM12/21/17
to iterm2-discuss
As much as I liked the potential of iTerm2/tmux integration, I stopped using it because of this window sizing issue. With large or multiple monitors the tmux sizing issue is a real limitation.

Instead I have moved to a model of starting a new tmux session for each iTerm2 window. So I open the window, mosh to server, and attach to a new session (or reattach). Much of this I have in scripts and mosh keeps me from having to redo things that often. One small issue is I need to create a new iTerm2 window and connect each time I want a new session (but I have that scripted). More painfully, I still can't get scrollback to work great and I miss iTerm2's search.

One workaround I have tried and dropped is to use -CC for each session. However, I end up with double the iTerm2 windows. One controlling iTerm2 window and one tmux iTerm2 window.

Upon reflection, an entire iTerm2 window dedicated to controlling the tmux session seems like more than is needed. So one thought I've had is that iTerm2 could move tmux control out of the iTerm2 window to the menu bar. That would mean when tmux -CC is run that the current iTerm2 window becomes the first tmux window. That seems to reduce clutter for most tmux users and definitely for anyone who wants a session per iTerm2 to get flexible window sizes.

Just a thought,
d

George Nachman

unread,
Dec 23, 2017, 5:37:34 PM12/23/17
to iterm2-...@googlegroups.com
On Thu, Dec 21, 2017 at 6:27 PM, David Rees <da...@ubiqsoft.com> wrote:
As much as I liked the potential of iTerm2/tmux integration, I stopped using it because of this window sizing issue. With large or multiple monitors the tmux sizing issue is a real limitation.

Instead I have moved to a model of starting a new tmux session for each iTerm2 window. So I open the window, mosh to server, and attach to a new session (or reattach). Much of this I have in scripts and mosh keeps me from having to redo things that often. One small issue is I need to create a new iTerm2 window and connect each time I want a new session (but I have that scripted). More painfully, I still can't get scrollback to work great and I miss iTerm2's search.

One workaround I have tried and dropped is to use -CC for each session. However, I end up with double the iTerm2 windows. One controlling iTerm2 window and one tmux iTerm2 window.

Upon reflection, an entire iTerm2 window dedicated to controlling the tmux session seems like more than is needed. So one thought I've had is that iTerm2 could move tmux control out of the iTerm2 window to the menu bar. That would mean when tmux -CC is run that the current iTerm2 window becomes the first tmux window. That seems to reduce clutter for most tmux users and definitely for anyone who wants a session per iTerm2 to get flexible window sizes.


There's a new feature that "buries" a session, which essentially hides it in the menu bar. That's the new default for the tmux gateway session.
 

David Rees

unread,
Jan 15, 2018, 7:22:27 PM1/15/18
to iterm2-...@googlegroups.com
Very cool. I hadn't seen that feature when it was added. That seems to be working great for ssh/tmux. I'm having an issue with mosh/tmux though. Will ask about that in a different thread.

--
You received this message because you are subscribed to a topic in the Google Groups "iterm2-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/iterm2-discuss/Etfozb_63Pg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to iterm2-discuss+unsubscribe@googlegroups.com.

Julian Elscher

unread,
Feb 23, 2018, 5:35:02 AM2/23/18
to iterm2-discuss
This has got to be one of the biggest annoyances with tmux integration
if you drag one window larger all your other windows screw up.
 there must be some clever way to connect to multiple tmux sessions?
I love connecting to a machine, typing one command and getting all 8 or 9 ( or more) sessions back
but the size thing really is annoying. Especially when moving from one machine to another with a different screen size.

I know its  a limitation in tmux, but have they thought about changing it?
or maybe we can add "screen" integration.  :-) 


George Nachman

unread,
Feb 27, 2018, 7:37:07 PM2/27/18
to iterm2-...@googlegroups.com
It's fixable but requires a good bit of work on tmux. I think the best approach would be to allow windows to be smaller than the size of the smallest attached client. iTerm2 could then advertise its size as bignum x bignum, or perhaps the max size of the current display, or something like that.

If someone wants to take this on, you'd need to do a few things:

1. Get the tmux maintainers onboard
2. Modify the tmux server to relax the requirement that all window sizes equal the size of the smallest client viewport
3. Modify the tmux client to handle varying size windows. It could be an extension of how the tmux client shows undersized windows (as it does when two clients are attached with different sized viewports)
4. Update tmux commands to allow the manipulation of window sizes

The changes to iTerm2 are modest in comparison, and I'd be glad to fix it up once tmux is ready.


--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discuss+unsubscribe@googlegroups.com.

David Petrou

unread,
May 13, 2019, 11:45:16 AM5/13/19
to iterm2-discuss
Hi George, just curious, has there been progress on this front? Is watching this thread the best place for updates, or is there a bug? It would be fantastic to have this ability. Thanks, David
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-...@googlegroups.com.

George Nachman

unread,
May 14, 2019, 2:42:49 AM5/14/19
to iterm2-...@googlegroups.com
Hey, David! Good to hear from you :). I decided to take a stab at it tonight and it seems feasible. It recently became easier because tmux gained the ability to support window sizes larger than the smallest client. I've got a start at it in my variable_size_windows branches of iTerm2 and tmux. I'll try to get it into reasonable shape this week and I'll respond on this thread when there's something testable.

To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iterm2-discuss/aea467b2-40bb-4af9-8075-fa564fad7b2d%40googlegroups.com.

David Petrou

unread,
May 14, 2019, 7:21:20 AM5/14/19
to iterm2-...@googlegroups.com
Hey George, yes, it's great to hear from you, too. I recognized your name. ;)

I'm so pleased to hear you're working on providing this functionality. Fingers crossed. I'll be very happy to test it when ready.

Thanks,
David


Rees, David

unread,
May 14, 2019, 4:06:42 PM5/14/19
to iterm2-...@googlegroups.com
Being able to handle different sized windows inside a single tmux session would be awesome. I'm still using my workaround of separate tmux sessions. It works, but is definitely kludgy. 

You received this message because you are subscribed to a topic in the Google Groups "iterm2-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/iterm2-discuss/Etfozb_63Pg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to iterm2-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iterm2-discuss/CABuN4_684fxFPG2on-5WZPYycDZ29HUULm6Gn7b75H2nLpZgBQ%40mail.gmail.com.

Julian Elischer

unread,
May 14, 2019, 6:24:09 PM5/14/19
to iterm2-...@googlegroups.com
looking forward to this.  (also mush integration for keeping sessions "open" )


For more options, visit https://groups.google.com/d/optout.


--

+----------------------------------\     ________ _  __
|   __--_|\  Julian Elischer        \--->x       U \/ / On assignment
|  /       \ jul...@elischer.org         \     USA    \ in a very strange
| (   OZ    ) 10826 NE 35th pl #1         \____   ___ | country !
+- X_.---._/ Bellevue WA USA                   \_/   \\
          v

George Nachman

unread,
May 15, 2019, 3:08:02 AM5/15/19
to iterm2-...@googlegroups.com
I landed commit 790352a which implements support for variable window sizes just under the wire for the nightly build, which will be out in a few minutes. Give it a try.

Requirements:
1. tmux 2.9a
2. Turn on **Prefs > Advanced > Allow variable window sizes in tmux integration**

* Fonts are allowed to vary from tab to tab, but are locked within a tab
* All tabs in a window will be the same size, as you'd expect
* The size of windows in a single tmux session may vary
* For now, profiles are not restored when re-attaching, so if you change fonts you'll lose that. I have a note to improve this.
* If you attach a plain-old (non integration) tmux client you'll want to do `resize-window -a` on each and every window to get them back to all being the same size. That's kinda lame. If anyone cares, it might be worth adding a new option to tmux's resize-window command to apply it to all windows in the session.

This thing is devilishly complex and hard to test. Please let me know if you have problems: file an issue at https://iterm2.com/bugs, and include a debug log (keeping it as simple as possible) along with a screen cap video.

Rees, David

unread,
Jul 29, 2019, 2:56:59 PM7/29/19
to iterm2-...@googlegroups.com
FYI, I tried this out with 3.3.0beta16. It works fine on my local Mac, but in a remote ssh session I still get window resizing. I filed a bug at https://gitlab.com/gnachman/iterm2/issues/7970. Thanks!

Message has been deleted

George Nachman

unread,
Dec 11, 2019, 2:05:32 AM12/11/19
to iterm2-...@googlegroups.com
Check Prefs>General>tmux>Open tmux windows as. If you set it to "Native Windows" then it will preserve your windows and tabs. I expect you may have it set to "tabs in the attaching window", which does lose those settings.

image.png

On Tue, Dec 10, 2019 at 12:06 AM Roee Bar <roe...@gmail.com> wrote:
This works well, however, the windows arrangement is lost when re-attaching (all windows become tabs in one window). Saving windows arrangement and restoring after re-attach also doesn't work. Is there a workaround for this?
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "iterm2-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/iterm2-discuss/Etfozb_63Pg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to iterm2-...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "iterm2-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/iterm2-discuss/Etfozb_63Pg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to iterm2-...@googlegroups.com.


--

+----------------------------------\     ________ _  __
|   __--_|\  Julian Elischer        \--->x       U \/ / On assignment
|  /       \ jul...@elischer.org         \     USA    \ in a very strange
| (   OZ    ) 10826 NE 35th pl #1         \____   ___ | country !
+- X_.---._/ Bellevue WA USA                   \_/   \\
          v

--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.

David Rees

unread,
Mar 15, 2020, 1:32:37 PM3/15/20
to iterm2-discuss
This is working great for me and feels like it is out of beta. If so, should it be added to the docs (they still say windows have to be the same size).

George Nachman

unread,
Apr 9, 2020, 9:30:39 PM4/9/20
to iterm2-...@googlegroups.com
FYI I enabled this by default in the 3.3.10 betas, and it will be on by default in 3.3.10.

To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iterm2-discuss/d9e89f30-3465-43b9-8038-8db09835df47%40googlegroups.com.

André Pang

unread,
May 27, 2020, 1:16:51 PM5/27/20
to iterm2-discuss
George, just wanted to say thank you for landing this feature. I stopped using the iTerm2 + tmux integration since requiring the same window/font size just wasn't working great, but it's a total joy to use it now that we can have individually-sized windows and fonts. I really appreciate the work you did on this!

George Nachman

unread,
May 27, 2020, 2:38:35 PM5/27/20
to iterm2-...@googlegroups.com
Thanks, André! Glad it's working well for you :)

To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iterm2-discuss/e3329d9a-6841-4456-8192-474486f31cf3%40googlegroups.com.

Julian Elischer

unread,
May 27, 2020, 3:58:55 PM5/27/20
to iterm2-discuss
yes, I added my voice above to ask for this. and now it's really amazing to use it.. With WFH tmux integration is now part of my every day activity.

BTW, being able to write shell scripts on the target machine that use the 'tmux new-session'  (etc) command to open up new windows from the target end has totally changed the way I do some tasks.. If my linux box needs to tell me about something it just pops up a new window on my mac..  Awesome! 

Reply all
Reply to author
Forward
0 new messages