libtmux Reference MCP Search
On this page

libtmux.Pane.split

View as Markdown

Module
libtmux
Declared in
Pane
Package
libtmux
Source
src/libtmux/pane.py
Other languages
TypeScriptRustGoJava.NETC++Swift
split
( 17 parameters ) ( self , target : int | str | None = None , start_directory : StrPath | None = None , attach : bool = False , direction : PaneDirection | None = None , full_window_split : bool | None = None , zoom : bool | None = None , shell : str | None = None , size : str | int | None = None , percentage : int | None = None , environment : dict[str, str] | None = None , empty : bool | None = None , style : str | None = None , active_border_style : str | None = None , inactive_border_style : str | None = None , message : str | None = None , keep : bool | None = None )
Pane
method [source]
method [source]
split

Split window and return Pane , by default beneath current pane.

Examples

>>> (pane.at_left, pane.at_right,
...  pane.at_top, pane.at_bottom)
(True, True,
True, True)
>>> new_pane = pane.split()
>>> (new_pane.at_left, new_pane.at_right,
...  new_pane.at_top, new_pane.at_bottom)
(True, True,
False, True)
>>> right_pane = pane.split(direction=PaneDirection.Right)
>>> (right_pane.at_left, right_pane.at_right,
...  right_pane.at_top, right_pane.at_bottom)
(False, True,
True, False)
>>> left_pane = pane.split(direction=PaneDirection.Left)
>>> (left_pane.at_left, left_pane.at_right,
...  left_pane.at_top, left_pane.at_bottom)
(True, False,
True, False)
>>> top_pane = pane.split(direction=PaneDirection.Above)
>>> (top_pane.at_left, top_pane.at_right,
...  top_pane.at_top, top_pane.at_bottom)
(False, False,
True, False)
>>> pane = session.new_window().active_pane
>>> top_pane = pane.split(direction=PaneDirection.Above, full_window_split=True)
>>> (top_pane.at_left, top_pane.at_right,
...  top_pane.at_top, top_pane.at_bottom)
(True, True,
True, False)
>>> bottom_pane = pane.split(
... direction=PaneDirection.Below,
... full_window_split=True)
>>> (bottom_pane.at_left, bottom_pane.at_right,
...  bottom_pane.at_top, bottom_pane.at_bottom)
(True, True,
False, True)
Parameters
  • target ( int | str | None ) – Optional, custom *target-pane*, used by Window.split .

  • start_directory ( StrPath | None ) – specifies the working directory in which the new window is created.

  • attach ( bool ) – make new window the current window after creating it, default True.

  • direction ( PaneDirection | None ) – split in direction. If none is specified, assume down.

  • full_window_split ( bool | None ) – split across full window width or height, rather than active pane.

  • zoom ( bool | None ) – expand pane

  • shell ( str | None ) – execute a command on splitting the window. The pane will close when the command exits. NOTE: When this command exits the pane will close. This feature is useful for long-running processes where the closing of the window upon completion is desired.

  • size ( str | int | None ) – Cell/row count to occupy with respect to current window.

  • percentage ( int | None ) – Percentage (0-100) of the window to occupy (-p flag). Mutually exclusive with *size*. added 0.56

  • environment ( dict[str, str] | None ) – Environmental variables for new pane. Passthrough to -e.

  • empty ( bool | None ) – Create an empty pane with no command (-E flag) instead of spawning the default shell. Requires tmux 3.7+. If used with tmux < 3.7, a warning is issued and the flag is ignored.

  • style ( str | None ) – Style for the new pane (-s). Requires tmux 3.7+.

  • active_border_style ( str | None ) – Active-pane border style (-S). Requires tmux 3.7+.

  • inactive_border_style ( str | None ) – Inactive-pane border style (-R). Requires tmux 3.7+.

  • message ( str | None ) – Keep the pane open (until a key is pressed) after exit, showing this remain-on-exit-format message (-m). Requires tmux 3.7+.

  • keep ( bool | None ) – Keep the pane open until a key is pressed after exit (-k). Requires tmux 3.7+. These 3.7 flags warn and are ignored below 3.7.

In other languages Split a pane in two

Examples

>>> (pane.at_left, pane.at_right,
...  pane.at_top, pane.at_bottom)
(True, True,
True, True)
>>> new_pane = pane.split()
>>> (new_pane.at_left, new_pane.at_right,
...  new_pane.at_top, new_pane.at_bottom)
(True, True,
False, True)
>>> right_pane = pane.split(direction=PaneDirection.Right)
>>> (right_pane.at_left, right_pane.at_right,
...  right_pane.at_top, right_pane.at_bottom)
(False, True,
True, False)
>>> left_pane = pane.split(direction=PaneDirection.Left)
>>> (left_pane.at_left, left_pane.at_right,
...  left_pane.at_top, left_pane.at_bottom)
(True, False,
True, False)
>>> top_pane = pane.split(direction=PaneDirection.Above)
>>> (top_pane.at_left, top_pane.at_right,
...  top_pane.at_top, top_pane.at_bottom)
(False, False,
True, False)
>>> pane = session.new_window().active_pane
>>> top_pane = pane.split(direction=PaneDirection.Above, full_window_split=True)
>>> (top_pane.at_left, top_pane.at_right,
...  top_pane.at_top, top_pane.at_bottom)
(True, True,
True, False)
>>> bottom_pane = pane.split(
... direction=PaneDirection.Below,
... full_window_split=True)
>>> (bottom_pane.at_left, bottom_pane.at_right,
...  bottom_pane.at_top, bottom_pane.at_bottom)
(True, True,
False, True)
const created = await pane.split({ vertical: true });
created.id;
use libtmux::{PaneSize, SplitDirection, SplitOptions};

let session = server.new_session("split-from-pane").await?;
let pane = session.panes().await?.remove(0);

let above = pane
    .split(
        SplitOptions::new(SplitDirection::Above)
            .size(PaneSize::Percent(30))
            .command("sleep 300"),
    )
    .await?;

assert_ne!(above.id(), pane.id());
assert_eq!(above.window_id(), pane.window_id());

0 declared, 0 inherited

Esc

Type to search.