# tmux_window:respawn/2

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

```
respawn(Window, Options)
-spec respawn(tmux_model:window(), respawn_options()) ->
                 {ok, tmux_operation:completed()} |
                 {error, tmux_operation:failure()}.
```

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.

launch defaults to previous and reuses the retained pane's saved command.
Explicit argv and shell maps, saved cwd and fresh-spawn environment rules
follow `tmux_pane:respawn/2`, using the resolved session's environment. This
physical-window mutation affects every link. Performs I/O after validation and
returns the command result without refreshing rows. Use `get/2` or a new
snapshot for current data.

## Parameters

- `Window` (`tmux_model:window()`)
- `Options` (`respawn_options()`)

## tmux command

The tmux commands behind `respawn/2`.

- [`respawn-window`](/en/tmux/latest/manual/respawn-window/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_respawn_window_entry`](/en/tmux/latest/reference/c-variable-cmd_respawn_window_entry/) (attribute)
- [`cmd_respawn_window_exec`](/en/tmux/latest/reference/c-function-cmd-respawn-window-c-cmd_respawn_window_exec/) (function)

## In other ports

Restart the command in a window's active pane

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Window.respawn`](/en/py/latest/reference/libtmux-window-respawn/) (method) |
| Ruby | [`LibTmux::Window#respawn`](/en/ruby/latest/reference/libtmux-window-respawn/) (method) |
| Lua | [`libtmux.Window:respawn`](/en/lua/latest/reference/libtmux-window-respawn/) (method) |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | [`window.Window.respawn`](/en/ts/latest/reference/window-window-respawn/) (method) |
| Rust | [`window.Window.respawn`](/en/rs/latest/reference/window-window-respawn/) (method) |
| Go | [`tmux.Window.Respawn`](/en/go/latest/reference/tmux-window-respawn/) (method) |
| Java | [`io.github.libtmux.Window.respawn`](/en/java/latest/reference/io-github-libtmux-window-window-respawn/) (method) |
| C# | [`LibTmux.Window.RespawnAsync`](/en/csharp/latest/reference/libtmux-window-respawnasync/) (method) |
| C++ | no equivalent on `Window` |
| Swift | no equivalent on `Window` |
| OCaml | No direct public OCaml equivalent is recorded for this operation. |
| Perl | No dedicated equivalent in the selected Perl surface. Explicit Server::cmd remains available for native tmux commands. |

No equivalent is recorded in PowerShell, Julia, Elixir, Common Lisp, Clojure, Kotlin, Scala or F#.
