TabGroup

Provides a class that represents an iTerm2 tab group.

class TabGroup(connection, group_id: str, name: str, color: Color | None, collapsed: bool)

Represents a tab group.

A tab group is a named, colored collection of adjacent tabs in a window. Its members are always kept consecutive in the tab bar: iTerm2 reorders tabs as needed to maintain that invariant when membership changes.

Don’t create this yourself. Instead, get one from iterm2.Tab.tab_group or iterm2.Window.tab_groups, or create one with iterm2.Window.async_create_tab_group().

The name, color, and collapsed values reflect the state at the time this object was fetched. After a mutation, re-fetch the app to observe the updated state.

async async_set_collapsed(collapsed: bool) → bool

Collapses or expands the group.

Collapsing hides the group’s members in the tab bar. It can be refused when the group comprises the entire window (there would be no tab left to select), in which case this returns False.

Return type:

bool

Parameters:

collapsed (bool) – True to collapse, False to expand.

Returns:

The group’s collapsed state after the change.

Throws:

RPCException if something goes wrong.

async async_set_color(color: Color) → None

Changes the group’s color. The new color applies to every member tab.

Parameters:

color (Color) – The new color.

Throws:

RPCException if something goes wrong.

async async_set_name(name: str) → None

Renames the group. The new name applies to every member tab.

Parameters:

name (str) – The new name.

Throws:

RPCException if something goes wrong.

property collapsed: bool
Returns:

Whether the group is collapsed (its members hidden in the tab bar).

property color: Color | None
Returns:

The group’s color, or None if it has none.

property group_id: str

A tab group’s unique identifier.

The identity is stable: it travels with the group’s tabs, even if they are dragged to another window.

Returns:

The group’s identifier, a string.

property name: str
Returns:

The group’s name, as shown in its tab-bar chip.


Indices and tables