# LibTmux\Move-TmuxWindow

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

```
Move-TmuxWindow
    [-Window] <LibTmux.Window>
    [-DestinationSession <LibTmux.Session>]
    [-Index <System.Nullable[System.Int32]>]
    [-Direction <System.Nullable[LibTmux.WindowDirection]>]
    [-NoSelect]
    [-ReplaceExisting]
    [-PassThru]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
```

Move one session placement of a window.

Move only the placement captured in the source [`Window`](/en/csharp/latest/reference/libtmux-window/) handle. Other links to
the same physical window remain in their sessions. Omit DestinationSession to
move within the source session. Omit Index to let tmux use the next free
index in the destination. A supplied destination [`Session`](/en/csharp/latest/reference/libtmux-session/) must belong to the
same endpoint and daemon generation as the [`Window`](/en/csharp/latest/reference/libtmux-window/).

With PassThru, return a new [`Window`](/en/csharp/latest/reference/libtmux-window/) handle containing the observed destination
placement. The original handle remains unchanged and is stale after a move.
Without PassThru, emit no success object. Confirmation is requested by
default because ReplaceExisting can remove a destination window. [`WhatIf`](/en/powershell/latest/reference/libtmux-move-tmuxwindow/#LibTmux%5CMove-TmuxWindow.parameter.WhatIf)
performs no tmux I/O.

### Notes

The core checks captured source placement and server generation before the
move. A stale placement, tmux rejection or failed readback writes a per-input
[`Tmux.WindowMoveFailed`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/Move-TmuxWindow.md#notes) error. Readback failure after dispatch has unknown final
state; inspect topology before deciding whether to retry. [`ErrorAction`](/en/powershell/latest/reference/libtmux-move-tmuxwindow/#LibTmux%5CMove-TmuxWindow.parameter.ErrorAction)
Continue permits later inputs; [`ErrorAction`](/en/powershell/latest/reference/libtmux-move-tmuxwindow/#LibTmux%5CMove-TmuxWindow.parameter.ErrorAction) Stop stops at the first failure.

## 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:** `LibTmux.Window`

Related APIs:

- [`New-TmuxWindowLink`](/en/powershell/latest/reference/libtmux-new-tmuxwindowlink/)
- [`Remove-TmuxWindowLink`](/en/powershell/latest/reference/libtmux-remove-tmuxwindowlink/)

## Examples

Example 1

Move the previously selected $window to index 5 in its own session and emit
the replacement handle. Assign the output for subsequent operations.

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

```powershell
$window | LibTmux\Move-TmuxWindow -Index 5 -PassThru -Confirm:$false
```

## Parameters

- `Window` (`LibTmux.Window`): The native source placement, supplied directly or through the pipeline.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `DestinationSession` (`LibTmux.Session`): Move into this native session. Omit it to use the source Window's captured
session. A different endpoint or daemon generation is rejected before tmux
dispatch.
  Optional. 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]`): The destination session's window index, at least 0. Omit it to use the next
free index.
  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
window relative to the destination session's current window.
  Optional. Named parameter. Does not accept pipeline input.
- `NoSelect` (`System.Management.Automation.SwitchParameter`): Leave the moved window unselected in the destination session.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input.
- `ReplaceExisting` (`System.Management.Automation.SwitchParameter`): Replace a link already at the requested destination index. This may destroy
the displaced window if it had no other links.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input.
- `PassThru` (`System.Management.Automation.SwitchParameter`): Emit a new Window handle with the destination placement read back after tmux
accepts the move. A failed readback does not mean the move was rolled back.
  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

`LibTmux.Window`: One replacement Window per successful input when PassThru is present;
otherwise no success output.
