Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

View as Markdown

Module
window
Package
libtmux
Source
crates/libtmux/src/window.rs
Other languages
PythonRubyLuaTypeScriptGoJava.NETC++Swift
struct window.Window
structoverload [source]
structoverload [source]
struct window.Window

One tmux window, as reached through one session that links it.

A window is not owned by a single session. link-window makes the same underlying window appear in several sessions at once, so discovery returns one Window per link rather than per window. Two handles for the same window reached through different sessions are not equal: they describe different places in the hierarchy.

Getters that describe the window itself, such as Window::name , read the window. Getters that describe its place in a session, such as Window::index and Window::is_active , read the link.

Discussed in Environment

In other ports A tmux window

Examples

use libtmux::SplitDirection;
let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("work").await?;
let window = session.active_window().await?.expect("a session has a window");
// Splitting is detached by default, so focus stays where it was.
window.split(SplitDirection::Below).await?;
assert_eq!(window.panes().await?.len(), 2);
guard.shutdown().await?;
>>> window = session.new_window('My project', attach=True)
>>> window
Window(@2 2:My project, Session($... ...))

Windows have panes:

>>> window.panes
[Pane(...)]
>>> window.active_pane
Pane(...)

Relations moving up:

>>> window.session
Session(...)
>>> window.window_id == session.active_window.window_id
True
>>> window == session.active_window
True
>>> window in session.windows
True

The window can be used as a context manager to ensure proper cleanup:

>>> with session.new_window() as window:
... pane = window.split()
... # Do work with the pane
... # Window will be killed automatically when exiting the context

57 declared, 0 inherited

Members

  • panes method List this window's panes, preserving any failure.
  • search_panes method The panes under this window that a matcher accepts, reporting why if the listing fails.
  • select_layout method Set the window's pane layout.
  • kill method Kill the window, closing it in every session that links it.
  • rename method Rename the window and update this handle.
  • link_to method Link this window into another session, so both hold the same window.
  • split method Split this window and return the new pane.
  • unlink method Remove this session's link to the window, leaving other links intact.
  • select method Make this window active in the session it was reached through.
  • options method Read every option set at this window, decoded by its declared kind.
  • id method Return the tmux window identity.
  • name method Return the window name.
  • resize method Resize the window to an exact size in cells.
  • move_to method Move this window to an index, possibly in another session.
  • rotate method Move the window's panes round one position, keeping the layout.
  • height method Return the window height in cells.
  • width method Return the window width in cells.
  • next_layout method Move to the next named layout, and return the window.
  • respawn method Restart the window's command in place.
  • swap_with method Swap this window's position with another.
  • session method Return the session this window was reached through.
  • active_pane method Return the window's active pane.
  • set_option method Set one option to text, unchecked.
  • unset_option method Remove one option, restoring whatever it inherits.
  • index method Return the window's index within Window::session_id .
  • refresh method Replace this handle's snapshot with the window's current state.
  • previous_layout method Move to the previous named layout, and return the window.
  • typed_option method Read one option, decoded according to what tmux declares about it.
  • set_hook method Set one hook to a tmux command.
  • unset_hook method Remove one hook.
  • is_active method Report whether this window is the active one in its session.
  • layout method Return the window's pane layout string.
  • last_pane method Move to the pane that was active before this one, and return it.
  • pane_count method Return how many panes the window contains.
  • linked_sessions method The sessions this window is linked into, reporting why if it cannot.
  • display method Show a message on the clients viewing this window.
  • cmd method Run a raw tmux command against this window.
  • session_id method Return the session this handle reached the window through.
  • last_activity method Return when the window last produced output.
  • is_linked method Report whether the window is linked into more than one session.
  • set_hooks method Write a whole hook at once.
  • from_env method Find the window this process is running in.
  • focus_direction method Move focus one pane in this direction, and report where it landed.
  • format method Expand a tmux format string in this window's context.
  • get method Read one field of this window's snapshot, named by the handle that filters it.
  • hook method Read one hook's commands, or None when it holds nothing.
  • resize_by method Resize the window to an exact size in cells.
  • set_typed_option method Set one option to a typed value, checked before it is sent.
  • append_option method Append to one option rather than replacing it.
  • from_env_value method Find a window from an explicit TMUX_PANE value.
  • has_activity method Report whether the window has unseen activity in this session.
  • has_bell method Report whether the window rang a bell in this session.
  • is_zoomed method Report whether one of the window's panes is zoomed to fill it.
  • option_names method List the option names set at this window's scope.
  • pane_at method Find this window's pane at the given index.
  • refreshed method Return a new handle holding the window's current state.
  • with_pane method Create a pane, run an operation with it, then kill it.
Esc

Type to search.