window arrangement inside of a new tab

19 views
Skip to first unread message

Arkadiusz Miśkiewicz

unread,
Apr 7, 2026, 3:49:55 PM (7 days ago) Apr 7
to iterm2-...@googlegroups.com

Hello.

On startup I have my iterm2 setup so it opens with window arrangement
(1/2 split and then 2x1/4 split of one half for example). That works nicely.

Two questions:
1) how not to get such split automatically done on every new tab?

2) and could there be a different window arrangement to choose via right
mouse -> new tab -> profile somehow (I guess there would have to be per
profile default arrangement setting)

How to approach this?

--
Arkadiusz Miśkiewicz, arekm / ( maven.pl | pld-linux.org )

Arkadiusz Miśkiewicz

unread,
Apr 7, 2026, 6:07:03 PM (7 days ago) Apr 7
to iterm2-...@googlegroups.com
On 07/04/2026 21:49, Arkadiusz Miśkiewicz wrote:
>
> Hello.
>
> On startup I have my iterm2 setup so it opens with window arrangement
> (1/2 split and then 2x1/4 split of one half for example). That works
> nicely.
>
> Two questions:
> 1) how not to get such split automatically done on every new tab?
>
> 2) and could there be a different window arrangement to choose via right
> mouse -> new tab -> profile somehow (I guess there would have to be per
> profile default arrangement setting)
>
> How to approach this?
>

Python bindings are so capable. And AIs, too... Problem solved (a bit
differently from initial question.
tabsplit.py

Arkadiusz Miśkiewicz

unread,
Apr 8, 2026, 3:09:59 AM (6 days ago) Apr 8
to iterm2-...@googlegroups.com

>> How to approach this?
>>
>
> Python bindings are so capable. And AIs, too... Problem solved (a bit
> differently from initial question.

I'm playing with this more and there seem to be no way to move session
to another tab from python api.

The only workaround seems to be:
await session.async_activate()
await iterm2.MainMenu.async_select_menu_item(
connection, "Move Session to Tab")

but it's very limited (current focused session, creates new tab instead
of me point on desired tab, no direct info on where it went etc).


Some

Session.async_move_to_tab(tab=None) (None = create a new tab)

is what I'm looking for. Is that doable in stable or in nightly somehow?

Thanks,

George Nachman

unread,
Apr 11, 2026, 1:06:24 PM (3 days ago) Apr 11
to iterm2-...@googlegroups.com
Hi,

There is actually an API for this already, though I realize it's missing from the documentation (I'll fix that). The App class has an async_move_session method that can move a session between tabs and even between windows. It's been available since 3.5.0beta11.

It works by specifying a destination session (one that's already in the target tab), and the moved session gets split next to it:

await app.async_move_session(
    session=session_to_move,
    destination=session_in_target_tab,
    split_vertically=True,
    before=False)

If you want to move a session to a brand new tab by itself, there's a workaround since async_move_session always creates a split:

# Create a new tab (comes with a default session)
new_tab = await window.async_create_tab()
throwaway = new_tab.current_session

# Move the session into the new tab
await app.async_move_session(
    session=session_to_move,
    destination=throwaway,
    split_vertically=True,
    before=False)

# Close the throwaway session
await throwaway.async_close(force=True)

I know the create-move-close dance isn't ideal. I have a better solution in progress but it won't be ready for a while. In the meantime, this should get you unblocked.


--
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.
To view this discussion visit https://groups.google.com/d/msgid/iterm2-discuss/ea7b0556-f0ce-456c-8b2f-83908f672907%40maven.pl.

George Nachman

unread,
Apr 12, 2026, 5:05:14 PM (2 days ago) Apr 12
to iterm2-...@googlegroups.com
I added two new methods on Session in commit 0e3f995483a5c7488f10e51659b5981b298bed5e, which will be available in the next nightly build and require iterm2 module version 2.15:

async_move_to_new_tab(window=None, tab_index=None)

Moves a session out of a split pane into its own tab.

- window: Which window to create the tab in. None means the session's current window.
- tab_index: Position in the tab bar (0 = first). None places it after the session's current tab (same window) or at the end
(different window).
- Returns the new tab's ID, or None for tmux clients (which are moved asynchronously by the server).

async_move_to_new_window()

Moves a session out of a split pane into a new window.

- Returns the new window's ID, or None for tmux clients.

The existing App.async_move_session(session, destination, split_vertically, before) continues to handle the case of moving a
session into a split pane alongside another session.

Example usage:

app = await iterm2.async_get_app(connection)
window = app.windows[0]
tab = window.tabs[0]
session = tab.sessions[0]

# Move to a new tab in the same window
tab_id = await session.async_move_to_new_tab()

# Move to a new tab in a different window, at position 0
tab_id = await session.async_move_to_new_tab(
 window=app.windows[1], tab_index=0)

# Move to a new window
window_id = await session.async_move_to_new_window()

These require the session to be one of at least two sessions in its tab (otherwise there's nothing to extract it from).
Reply all
Reply to author
Forward
0 new messages