# libtmux.Window.respawn

- **Module:** libtmux
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/window.py#L1082
- **Page:** https://libtmux.org/en/py/stable/reference/libtmux-window-respawn/

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

```
libtmux.Window.respawn(
    self,
    shell: str | None = None,
    start_directory: StrPath | None = None,
    environment: dict[str, str] | None = None,
    kill: bool | None = None,
) -> None
```

Respawn the window process via [`$ tmux respawn-window`](/en/tmux/latest/manual/respawn-window/).

## Examples

```python
>>> window = session.new_window(window_name='respawn_test')
>>> window.respawn(kill=True, shell='sh')
```

## Parameters

- `shell` (`str | None`): Shell command to run in the respawned window.
- `start_directory` (`StrPath | None`): Working directory for the respawned window (``-c`` flag).
- `environment` (`dict[str, str] | None`): Environment variables (``-e`` flag).
- `kill` (`bool | None`): Kill the current process before respawning (``-k`` flag).
Required if the window is still active.

## In other ports

### Restart the command in a window's active pane

- Ruby: [`LibTmux::Window#respawn`](/en/ruby/latest/reference/libtmux-window-respawn/) (method)
- Lua: [`libtmux.Window:respawn`](/en/lua/latest/reference/libtmux-window-respawn/) (method)
- 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.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)
