# libtmux.Window.link

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

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

```
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`](/en/tmux/latest/manual/link-window/).

## Examples

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

## Parameters

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

## In other ports

### Link a window into another session

- Ruby: [`LibTmux::Session#link_window`](/en/ruby/latest/reference/libtmux-session-link_window/) (method)
- Lua: [`libtmux.WindowLink:link`](/en/lua/latest/reference/libtmux-windowlink-link/) (method)
- TypeScript: [`window.Window.link`](/en/ts/latest/reference/window-window-link/) (method)
- Rust: [`window.Window.link_to`](/en/rs/latest/reference/window-window-link_to/) (method)
- Go: [`tmux.Window.Link`](/en/go/latest/reference/tmux-window-link/) (method)
- Java: [`io.github.libtmux.Window.Window.linkTo`](/en/java/latest/reference/io-github-libtmux-window-window-linkto/) (method)
- C#: [`LibTmux.Window.LinkAsync`](/en/csharp/latest/reference/libtmux-window-linkasync/) (method)
- C++: [`libtmux::Window::link_to`](/en/cxx/latest/reference/libtmux-window-link_to/) (method)
- Swift: [`Server.link(_:into:)`](/en/swift/latest/reference/server-link(_-into-)/) (method)
