# libtmux.Window.link

- **Module:** libtmux.Window
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/window.py#L964
- **Page:** https://libtmux.org/reference/py/libtmux-window-link/

```
libtmux.Window.link(self, target_session: str | Session, target_index: str | None = None, kill_existing: bool | None = None, after: bool | None = None, before: bool | None = None, detach: bool | None = None) -> None
```

Link this window to another session via ``$ tmux link-window``.

## Parameters

- `self`
- `target_session` (str | Session) — Target session to link the window to.
- `target_index` (str | None) — Target window index in the destination session.
- `kill_existing` (bool | None) — Kill target window if it exists (``-k`` flag).
- `after` (bool | None) — Insert after the target window (``-a`` flag).
- `before` (bool | None) — Insert before the target window (``-b`` flag).
- `detach` (bool | None) — Do not make the linked window active (``-d`` flag).

## Example

```python
>>> w = session.new_window(window_name='link_test')
>>> s2 = server.new_session(session_name='link_target')
>>> w.link(s2)
```
