# LibTmux\New-TmuxWindowLink

- **Package:** LibTmux
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.PowerShell/NewTmuxWindowLinkCommand.cs#L8
- **Page:** https://libtmux.org/en/powershell/latest/reference/libtmux-new-tmuxwindowlink/

```
New-TmuxWindowLink
    [-Window] <LibTmux.Window>
    -Session <LibTmux.Session>
    [-Index <System.Nullable[System.Int32]>]
    [-Direction <System.Nullable[LibTmux.WindowDirection]>]
    [-ReplaceExisting]
    [-NoSelect]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
```

Link a window into another session.

Link a captured window placement into a native destination [`Session`](/en/csharp/latest/reference/libtmux-session/). The
source handle must name a current session-relative link. The destination
must belong to the same endpoint and daemon generation. An existing link at
the requested index is an error unless ReplaceExisting is present.

This command does not emit a new placement. Read the destination session's
windows to work with its new link. The original [`Window`](/en/csharp/latest/reference/libtmux-window/) handle stays a capture
of the source placement. Confirmation is requested by default because
ReplaceExisting can remove a destination window. [`WhatIf`](/en/powershell/latest/reference/libtmux-new-tmuxwindowlink/#LibTmux%5CNew-TmuxWindowLink.parameter.WhatIf) performs no tmux I/O.

### Notes

A stale source placement or missing destination writes a per-input
[`Tmux.WindowLinkFailed`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/New-TmuxWindowLink.md#notes) error. [`ErrorAction`](/en/powershell/latest/reference/libtmux-new-tmuxwindowlink/#LibTmux%5CNew-TmuxWindowLink.parameter.ErrorAction) Continue processes later windows;
[`ErrorAction`](/en/powershell/latest/reference/libtmux-new-tmuxwindowlink/#LibTmux%5CNew-TmuxWindowLink.parameter.ErrorAction) Stop stops on the first failure. The core checks source placement
and server generation in tmux's native queue before mutating. Do not retry an
already dispatched mutation without observing current topology.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/reference/glossary/#cmdlet)
- **Confirmation:** Supports `-WhatIf` and `-Confirm`; confirm impact: High.
- **Positional binding:** Enabled.
- **Pipeline inputs:** `LibTmux.Window`: One native source placement per pipeline input.
- **Outputs:** `System.Void`

Related APIs:

- [`Move-TmuxWindow`](/en/powershell/latest/reference/libtmux-move-tmuxwindow/)
- [`Remove-TmuxWindowLink`](/en/powershell/latest/reference/libtmux-remove-tmuxwindowlink/)
- [`Remove-TmuxWindow`](/en/powershell/latest/reference/libtmux-remove-tmuxwindow/)

## Examples

Example 1

Link the previously selected $window into $guest at index 5 without selecting
it. Both handles must come from the same tmux server generation.

[Source example](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/New-TmuxWindowLink.md).

```powershell
$link = @{ Session = $guest; Index = 5; NoSelect = $true; Confirm = $false }
$window | LibTmux\New-TmuxWindowLink @link
```

## Parameters

- `Window` (`LibTmux.Window`): The native source placement, supplied directly or through the pipeline. A
physical window linked into multiple sessions has a distinct Window handle
for each placement.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `Session` (`LibTmux.Session`): The native destination session. Its endpoint and generation must match the
source Window.
  Required. Named parameter. Does not accept pipeline input. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `Index` (`System.Nullable[System.Int32]`): An index in the destination session, at least 0. Omit it to let tmux choose
the placement.
  Optional. Named parameter. Does not accept pipeline input. [`ValidateRange(0, 2147483647)`](https://learn.microsoft.com/dotnet/api/system.management.automation.validaterangeattribute?view=powershellsdk-7.4.0).
- `Direction` (`System.Nullable[LibTmux.WindowDirection]`): Insert Before or After the destination. Without Index, tmux places the link
relative to the destination session's current window.
  Optional. Named parameter. Does not accept pipeline input.
- `ReplaceExisting` (`System.Management.Automation.SwitchParameter`): Replace a link already at the requested index. This may destroy the displaced
window if it had no other links.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input.
- `NoSelect` (`System.Management.Automation.SwitchParameter`): Leave the new link unselected in its destination session.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input.
- `Verbose` (`System.Management.Automation.SwitchParameter`): Display verbose messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `vb`.
- `Debug` (`System.Management.Automation.SwitchParameter`): Display debug messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `db`.
- `ErrorAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to non-terminating errors.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ea`.
- `WarningAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to warning messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wa`.
- `InformationAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles information messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `infa`.
- `ProgressAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles progress updates.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `proga`.
- `ErrorVariable` (`System.String`): Store the command's error records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ev`.
- `WarningVariable` (`System.String`): Store the command's warning records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wv`.
- `InformationVariable` (`System.String`): Store the command's information records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `iv`.
- `OutVariable` (`System.String`): Save output in the named variable while passing it down the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ov`.
- `OutBuffer` (`System.Int32`): Buffer output before passing it to the next pipeline command.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ob`.
- `PipelineVariable` (`System.String`): Make the most recent output object available through a named variable within the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `pv`.
- `WhatIf` (`System.Management.Automation.SwitchParameter`): Runs the command in a mode that only reports what would happen without performing the actions.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `wi`.
- `Confirm` (`System.Management.Automation.SwitchParameter`): Prompts you for confirmation before running the cmdlet.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `cf`.

## Returns

`None`: No success objects are emitted.
