# tmux_pane:respawn/2

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

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

Respawn this registered physical pane, keeping its pane ID. force defaults false and a running pane normally returns command_error. force = true lets tmux close its existing PTY before spawning again. This acknowledges the tmux command, not former-job termination or successful application initialization. The old PTY can already be closed if a later spawn step fails.

launch defaults to previous, reusing tmux's saved argv or shell. An explicit
argv or shell map replaces that command. default_shell is invalid here because
absent respawn arguments mean saved-command reuse. Omitted cwd retains the
saved launch directory, rather than the program's current directory. env
augments the session environment tmux resolves for this physical pane; a
captured membership does not pin that context. Prior per-spawn overrides are
not automatically reapplied. Other launch rules follow
`tmux_session:create/2`.

Performs I/O after validation. Existing rows retain their observations; use
`get/2` and an application readiness condition to inspect the new process. An
uncertain result is not permission to replay this mutation automatically.

Unsupported launch modes fail before dispatch:

## Examples

```erlang
1> tmux_pane:respawn(invalid_row, #{launch => default_shell}).
{error,#{code => invalid_launch}}
```

## Parameters

- `Pane` (`tmux_model:pane()`)
- `Options` (`respawn_options()`)

## tmux command

The tmux commands behind `respawn/2`.

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

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_respawn_pane_entry`](/en/tmux/latest/reference/c-variable-cmd_respawn_pane_entry/) (attribute)
- [`cmd_respawn_pane_exec`](/en/tmux/latest/reference/c-function-cmd-respawn-pane-c-cmd_respawn_pane_exec/) (function)

## Guides

Pages that discuss `respawn/2`.

- [Owned operations](/en/erlang/latest/guides/operations/)

## In other ports

Restart a pane's command

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Pane.respawn`](/en/py/latest/reference/libtmux-pane-respawn/) (method) |
| Ruby | [`LibTmux::Pane#respawn`](/en/ruby/latest/reference/libtmux-pane-respawn/) (method) |
| Lua | [`libtmux.Pane:respawn`](/en/lua/latest/reference/libtmux-pane-respawn/) (method) |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | [`pane.Pane.respawn`](/en/ts/latest/reference/pane-pane-respawn/) (method) |
| Rust | [`pane.Pane.respawn`](/en/rs/latest/reference/pane-pane-respawn/) (method) |
| Go | [`tmux.Pane.Respawn`](/en/go/latest/reference/tmux-pane-respawn/) (method) |
| Java | [`io.github.libtmux.Pane.respawn`](/en/java/latest/reference/io-github-libtmux-pane-pane-respawn/) (method) |
| C# | [`LibTmux.Pane.RespawnAsync`](/en/csharp/latest/reference/libtmux-pane-respawnasync/) (method) |
| C++ | [`libtmux::Pane::respawn`](/en/cxx/latest/reference/libtmux-pane-respawn/) (method) |
| Swift | [`Server.respawn(_:running:killingExisting:)`](/en/swift/latest/reference/server-respawn(_-running-killingexisting-)/) (method) |
| OCaml | [`Libtmux_unix.Client.respawn_pane`](/en/ocaml/latest/reference/libtmux_unix-client-respawn_pane/) (function) |
| 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#.
