# LibTmux.Workspace\ConvertTo-TmuxWorkspace

- **Package:** LibTmux.Workspace
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.Workspace.PowerShell/ConvertToTmuxWorkspaceCommand.cs#L8
- **Page:** https://libtmux.org/en/powershell/latest/workspace/reference/libtmux-workspace-convertto-tmuxworkspace/

```
ConvertTo-TmuxWorkspace
    [-Session] <LibTmux.Session>
    [<CommonParameters>]
```

Convert a captured session to a native workspace declaration.

Return one native WorkspaceFile for each captured [`Session`](/en/csharp/latest/reference/libtmux-session/) received from the
pipeline. The shared library preserves captured window placements and pane order,
names, layouts, active window and pane flags, and pane directories. Repeated links
to the same window become separate declared windows.

Capture with [`Get-TmuxSnapshot`](/en/powershell/latest/reference/libtmux-get-tmuxsnapshot/) -Depth Panes before selecting a [`Session`](/en/csharp/latest/reference/libtmux-session/). Conversion
never contacts tmux or fills unavailable relations. The captured graph remains
convertible after its daemon exits. A missing field or relation is an error;
a captured null pane directory remains unspecified rather than using the host's
current directory.

Captured directories become unresolved declaration values with literal dollars
escaped as `$$`. DocumentDirectory remains null. Use [`Resolve-TmuxWorkspace`](/en/powershell/latest/workspace/reference/libtmux-workspace-resolve-tmuxworkspace/) with
an explicit BaseDirectory before planning, or convert the declaration to YAML
or JSON and resolve it after importing. Do not interpret those escaped values
as already resolved filesystem paths.

Conversion preserves session-relative window indices. It emits a warning for
each successful input because it omits observed environment, options,
terminal text, entity IDs, pane indices and shared-link identity.
It cannot reconstruct original commands, arguments or shell intent. Foreground
command names do not establish the shell command that started a pane. Original
relative paths, expansion variables, comments, host scripts and pre-commands
are not reconstructed. Native custom layouts can change which pane occupies a
position when applied. This declaration
is a starting configuration, not a checkpoint of running programs.

### Notes

[`Tmux.WorkspaceFreezeFailed`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux.Workspace/ConvertTo-TmuxWorkspace.md#notes) retains the original native exception and input
[`Session`](/en/csharp/latest/reference/libtmux-session/) as its target. [`IncompleteSnapshotException`](/en/csharp/latest/reference/libtmux-incompletesnapshotexception/) uses the InvalidData error
category. [`ErrorAction`](/en/powershell/latest/workspace/reference/libtmux-workspace-convertto-tmuxworkspace/#LibTmux.Workspace%5CConvertTo-TmuxWorkspace.parameter.ErrorAction) Continue permits later sessions to be converted without
emitting a declaration for a failed input; [`ErrorAction`](/en/powershell/latest/workspace/reference/libtmux-workspace-convertto-tmuxworkspace/#LibTmux.Workspace%5CConvertTo-TmuxWorkspace.parameter.ErrorAction) Stop terminates.
The loss warning uses PowerShell's warning stream and supports [`WarningAction`](/en/powershell/latest/workspace/reference/libtmux-workspace-convertto-tmuxworkspace/#LibTmux.Workspace%5CConvertTo-TmuxWorkspace.parameter.WarningAction).
The command performs no acquisition, execution or file write and has no WhatIf
or Confirm parameters.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/workspace/reference/glossary/#cmdlet)
- **Positional binding:** Enabled.
- **Pipeline inputs:** `LibTmux.Session`: A native captured session; serialized copies are not live native objects.
- **Outputs:** `LibTmux.Workspace.WorkspaceFile`

Related APIs:

- [`Get-TmuxSnapshot`](/en/powershell/latest/reference/libtmux-get-tmuxsnapshot/)
- [`Resolve-TmuxWorkspace`](/en/powershell/latest/workspace/reference/libtmux-workspace-resolve-tmuxworkspace/)
- [`ConvertTo-TmuxWorkspaceYaml`](/en/powershell/latest/workspace/reference/libtmux-workspace-convertto-tmuxworkspaceyaml/)
- [`ConvertTo-TmuxWorkspaceJson`](/en/powershell/latest/workspace/reference/libtmux-workspace-convertto-tmuxworkspacejson/)

## Examples

Example 1

Convert a native Session selected from a pane-depth snapshot. This operation
uses only the supplied capture and does not own resources requiring cleanup.

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

```powershell
$capturedSession | LibTmux.Workspace\ConvertTo-TmuxWorkspace
```

## Parameters

- `Session` (`LibTmux.Session`): The native session whose window, pane and active-pane relations and required
fields have already been captured. Binding by an arbitrary object's Session
property is not supported.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `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`.

## Returns

`LibTmux.Workspace.WorkspaceFile`: One unresolved declaration per successfully converted input session.
