# tmux_window

- **Package:** libtmux_erlang
- **Language:** Erlang
- **Kind:** module
- **Source:** https://github.com/libtmux/libtmux-erlang/blob/d1b6308440cf9eb8f6647e7ae434bce60e849368/apps/libtmux_erlang/src/tmux_window.erl#L1
- **Page:** https://libtmux.org/en/erlang/latest/reference/tmux_window/

Create physical windows in a session and act through their registered IDs.

`create/2` accepts name, cwd, env, launch and detach, using the
session's next available index. It defaults to detached. `get/2`
reads current fields; `rename/2` returns the command result and
leaves previous records unchanged. Launch and environment options follow
`tmux_session:create/2`. An empty shell command does not portably keep the
window alive: older tmux releases execute it as a shell command. Use a running
program when needed. Creation returns a fresh observed row or an error
retaining a completed mutation and its result if the follow-up observation
fails.

`kill/1` destroys the physical window and all its links. Use
`tmux_window_link:unlink/2` to remove one session membership. These calls
perform I/O after validating their inputs. `select_layout/2`
changes the physical window's layout across all its session links; previously
observed pane geometry remains unchanged in captured values.

## Members

### Common operations

- [`create/2`](/en/erlang/latest/reference/tmux_window-create-2/) (function): Create a physical window in the session's next free index and observe it. Defaults to detached. Launch, cwd and environment follow `tmux_session:create/2`. Performs I/O and retains completed-mutation details if observation fails.
- [`select_layout/2`](/en/erlang/latest/reference/tmux_window-select_layout-2/) (function): Select a built-in arrangement or restore a literal serialized layout for this registered physical window. Binary names must exactly match one of the five built-ins; abbreviations and other names are rejected. Legacy serialized layouts need four hexadecimal checksum digits, a comma and nonempty data. This guard avoids a malformed-header crash in tmux 3.3 and 3.3a.
- [`kill/1`](/en/erlang/latest/reference/tmux_window-kill-1/) (function): Destroy the physical window and all of its session links. This does not unlink only one membership. Performs I/O after origin and target validation.
- [`rename/2`](/en/erlang/latest/reference/tmux_window-rename-2/) (function): Rename the registered physical window with a literal name. Performs I/O and returns the command result. Captured rows and snapshots remain unchanged.
- [`respawn/2`](/en/erlang/latest/reference/tmux_window-respawn-2/) (function): Respawn a registered physical window across all its session links. tmux keeps the first pane's ID, removes the other panes and rebuilds a single-pane layout. force defaults false: a window with a running pane normally returns command_error. force = true permits closing existing PTYs. Command completion does not establish former-job termination or application readiness. Other panes can already be removed if a later spawn step fails. Respawn also selects this window in tmux's resolved session. For a window linked into several sessions, tmux chooses that context from the physical ID; this facade does not pin selection or environment to a captured membership.
- [`get/2`](/en/erlang/latest/reference/tmux_window-get-2/) (function): Explicitly read a physical window by stable ID. Returns a fresh record or target_gone. Physical windows do not have a universal session or window index.

### Other members

- [`create_options/0`](/en/erlang/latest/reference/t-tmux_window-create_options-0/) (typealias): Physical-window creation options; defaults to a detached window at the next free session index.
- [`layout/0`](/en/erlang/latest/reference/t-tmux_window-layout-0/) (typealias): A built-in arrangement, its exact binary name, or a serialized layout. Native JSON v2 requires tmux 3.8.
- [`respawn_options/0`](/en/erlang/latest/reference/t-tmux_window-respawn_options-0/) (typealias): Physical-window respawn options. Defaults: force false, launch previous, saved cwd. A forced respawn removes other panes.

## Guides

Pages that discuss `tmux_window`.

- [Native API documentation](/en/erlang/latest/guides/api-documentation/)
