# libtmux.Window.respawn

- **Module:** libtmux.Window
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/9fdd083a8181a827889337b63cd4e6daea661a8c/src/libtmux/window.py#L1101
- **Page:** https://libtmux.org/en/py/latest/reference/libtmux-window-respawn/

```
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``.

## Parameters

- `self`
- `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.

## Example

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