# LibTmux\Set-TmuxLayout

- **Package:** LibTmux
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.PowerShell/SetTmuxLayoutCommand.cs#L7
- **Page:** https://libtmux.org/en/powershell/latest/reference/libtmux-set-tmuxlayout/

```
Layout (default):
Set-TmuxLayout
    [-Window] <LibTmux.Window>
    -Layout <System.String>
    [-PassThru]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Mode:
Set-TmuxLayout
    [-Window] <LibTmux.Window>
    -Mode <LibTmux.SelectLayoutMode>
    [-PassThru]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
```

Arrange the panes of a window.

Apply a named preset or a captured window Layout string. Mode accepts [`Spread`](/en/csharp/latest/reference/libtmux-selectlayoutmode-spread/),
[`Next`](/en/csharp/latest/reference/libtmux-selectlayoutmode-next/) or [`Previous`](/en/csharp/latest/reference/libtmux-selectlayoutmode-previous/). The native core rejects unknown or ambiguous preset names
before dispatch. Without PassThru, emit no success output; with it, return a
replacement [`Window`](/en/csharp/latest/reference/libtmux-window/) and leave the original capture unchanged.

### Notes

Restoring a classic layout restores pane sizes but can rotate pane placement on
tmux 3.7 and earlier. It does not guarantee the same pane IDs occupy the same
positions. A disappeared target or stale generation writes a per-target error.
Use [`-ErrorAction`](/en/powershell/latest/reference/libtmux-set-tmuxlayout/#LibTmux%5CSet-TmuxLayout.parameter.ErrorAction) Stop to terminate. Cancellation cannot undo an already
dispatched change.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/reference/glossary/#cmdlet)
- **Default parameter set:** Layout
- **Confirmation:** Supports `-WhatIf` and `-Confirm`; confirm impact: Medium.
- **Positional binding:** Enabled.
- **Pipeline inputs:** `LibTmux.Window`: Native pipeline owner.
- **Outputs:** `LibTmux.Window`

Related APIs:

- [Task guide](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/layout.md)

## Examples

Example 1

Tile the panes in a previously selected native $window.

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

```powershell
$window | LibTmux\Set-TmuxLayout -Layout tiled -PassThru
```

## Parameters

- `Window` (`LibTmux.Window`): The native window to change.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `Layout` (`System.String`): A preset name, unambiguous preset prefix, or captured layout string. (for `Layout`)
  Required. Named parameter. Does not accept pipeline input. [`ValidateNotNullOrEmpty()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnulloremptyattribute?view=powershellsdk-7.4.0). [`ValidatePattern("\\A[^\\x00]*[^\\s\\x00][^\\x00]*\\z")`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatepatternattribute?view=powershellsdk-7.4.0).
- `PassThru` (`System.Management.Automation.SwitchParameter`): Emit the native replacement handle carrying observed state.
  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`): Preview the change without contacting tmux.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `wi`.
- `Confirm` (`System.Management.Automation.SwitchParameter`): Ask for confirmation before changing tmux.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `cf`.
- `Mode` (`LibTmux.SelectLayoutMode`): Spread panes or select the Next or Previous layout. (for `Mode`)
  Required. Named parameter. Does not accept pipeline input. [`ValidateSet(["Spread","Next","Previous"])`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatesetattribute?view=powershellsdk-7.4.0).

## Returns

`LibTmux.Window`: Emitted only with PassThru.
