# LibTmux.Window.link/5

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/lib/libtmux/entities.ex#L347
- **Page:** https://libtmux.org/en/elixir/pr-173/reference/libtmux-window-link-5/

```
link(connection, window, destination, index, options \\ [])
@spec link(
        LibTmux.Action.connection(),
        LibTmux.Ref.t(),
        LibTmux.Ref.t(),
        0..2_147_483_647,
        [LibTmux.Action.membership_option()]
      ) ::
        {:ok, LibTmux.Action.result(:ok)}
        | {:error, LibTmux.Action.error()}
```

Links an exact physical window at the given index in an exact session.

The two references must name the same live server incarnation. The index
is in 0..2147483647. tmux preserves the active window and reports a failed
outcome if the destination index is occupied. The window and its panes
remain shared across their memberships.

This action uses a Server. A Control connection returns
`:unsupported_transport`. A grouped destination returns `:grouped_session`
because tmux synchronizes membership across sessions in the group. The
default timeout is 5000ms. An incarnation check precedes the native
action and leaves the usual one-shot check/use race.

See the [worked example](one-shot-actions.html#share-a-physical-window).

## Parameters

- `connection` (`LibTmux.Action.connection()`)
- `window` (`LibTmux.Ref.t()`)
- `destination` (`LibTmux.Ref.t()`)
- `index` (`0..2_147_483_647`)
- `options` (`[LibTmux.Action.membership_option()]`)
  Default: `[]`.
