tmux integration: opening new tabs in the current window from shell

369 views
Skip to first unread message

Joey Korkames

unread,
Feb 16, 2016, 2:17:04 PM2/16/16
to iterm2-discuss
I use tmux-integrated windows a lot and sometimes I want to script their layouts in the shell instead of using an iTerm profile.
If I `tmux neww`, I end up with an new window instead of a new iTerm tab.

I don't see any nice way to specify "tabbyness" from the shell, but that state clearly exists if you reconnect to a tmux session with tabs created by iTerm hotkey.

`tmux show` displays iTerm's metadata for the windows and I've found how to "rejoin" them from the shell, but a disconnect & reconnect is required.
<545> $ tmux lsw
1: bash* (1 panes) [272x59] [layout d35d,272x59,0,0,0] @0 (active) #inital window
2: bash- (1 panes) [272x59] [layout d35f,272x59,0,0,2] @2 # hotkey'd new tab
3: bash  (1 panes) [272x59] [layout d360,272x59,0,0,3] @3 # shell'd new window

<546> $ tmux show
@affinities "pty-FF7BAFB7-29C3-4809-BCB7-BFF3C585BFC4; pty-7DAA0A7E-2163-4EB0-A78F-2C2C85160A5E;WindowStyle=FullScreen pty-2DB2B8C0-DE19-4489-837A-E5637AC6CC9C; pty-AA4757AA-6C6C-4339-BCDC-A482FE02D1C6;WindowStyle=FullScreen pty-B93D4284-BEC1-445E-8228-F91C26152F86; 0,2,pty-1FF8A8D1-10DE-4C38-8C0F-97311CE800CF;WindowStyle=FullScreen 3,pty-30095539-3357-4206-B7A0-BF7CB81917E8;WindowStyle=FullScreen"
@iterm2_id "26719F09-6C76-4BD5-A540-818B1CF2D62C"
@iterm2_size "272,59"
@origins "3:-480,900 0,2:-480,900"

<547> $ tmux set @origins "0,2,3:-480,900"

<548> $ tmux set @affinities "pty-FF7BAFB7-29C3-4809-BCB7-BFF3C585BFC4; pty-7DAA0A7E-2163-4EB0-A78F-2C2C85160A5E;WindowStyle=FullScreen pty-2DB2B8C0-DE19-4489-837A-E5637AC6CC9C; pty-AA4757AA-6C6C-4339-BCDC-A482FE02D1C6;WindowStyle=FullScreen pty-B93D4284-BEC1-445E-8228-F91C26152F86; 0,2,3,pty-1FF8A8D1-10DE-4C38-8C0F-97311CE800CF;WindowStyle=FullScreen"

# disconnected & reconnected, now have 3 tabs in one window

<549> $ tmux show
@affinities "pty-FF7BAFB7-29C3-4809-BCB7-BFF3C585BFC4; pty-7DAA0A7E-2163-4EB0-A78F-2C2C85160A5E;WindowStyle=FullScreen pty-2DB2B8C0-DE19-4489-837A-E5637AC6CC9C; pty-AA4757AA-6C6C-4339-BCDC-A482FE02D1C6;WindowStyle=FullScreen pty-D8B17BD8-3A03-4B0A-8015-A47A66DF9202; 0,2,3,pty-FBD143B6-28C4-4696-AB96-A6A7EBA438E7;WindowStyle=FullScreen"
@iterm2_id "26719F09-6C76-4BD5-A540-818B1CF2D62C"
@iterm2_size "270,59"
@origins "3,2,0:-480,900"

Is there a way to make iTerm "resync" its layout from the tmux options without doing a disconnect/reconnect?

George Nachman

unread,
Feb 18, 2016, 12:38:46 AM2/18/16
to iterm2-...@googlegroups.com
Unfortunately it's not currently possible to do this. When we're notified that a new window was created and it's not one we already know about, we always open it in a new native window.

We don't open it in a tab because it's not clear which native window it ought to go in.

It would be reasonable for there to be a way to specify a preference for this on the tmux command line. One way to do it would be to fiddle with the @affinities variable as you suggest. There's an unavoidable race condition as both you and iTerm2 want to change this variable at the same time; plus, iTerm2 changes it at unpredictable times, such as when a tmux window closes.

I'm not quite sure what the right answer is, but it will certainly require a change to iTerm2. Would you mind filing a feature request at iterm2.com/bugs so I can track this?

Thanks,
George

--
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.

Joey Korkames

unread,
Feb 18, 2016, 7:31:26 PM2/18/16
to iterm2-discuss


On Wednesday, February 17, 2016 at 9:38:46 PM UTC-8, George Nachman wrote:

I'm not quite sure what the right answer is, but it will certainly require a change to iTerm2. Would you mind filing a feature request at iterm2.com/bugs so I can track this?


Reply all
Reply to author
Forward
0 new messages