# Export and reload a session

Source: https://libtmux.org/en/csharp/latest/workspace/guides/export-session/

> Capture a running session, inspect the document and load a second copy.

Capture the session created by the [installation walkthrough](https://libtmux.org/en/csharp/latest/workspace/guides/installation/)
to a new YAML file:

```console
$ tmux-workspace freeze \
    -S "$WORKSPACE_TMP/tmux.sock" \
    --json \
    --workspace-format yaml \
    --save-to workspace-export.yaml \
    workspace-guide
```

Review the saved commands, directories and layout. Capture reads current tmux
state; it cannot recover original arguments, shell history, scripts, comments
or application state. A captured command may need editing before replay.

## Load a second copy

Use a fresh session name on the same private server:

```console
$ tmux-workspace load \
    -S "$WORKSPACE_TMP/tmux.sock" \
    -d \
    -s workspace-replayed \
    --json \
    workspace-export.yaml
```

Inspect the second copy's panes:

```console
$ tmux -S "$WORKSPACE_TMP/tmux.sock" list-panes -t '=workspace-replayed'
```

Remove that copy when finished:

```console
$ tmux -S "$WORKSPACE_TMP/tmux.sock" kill-session -t '=workspace-replayed'
```

[Capture](https://libtmux.org/en/csharp/latest/workspace/cli/freeze/) explains destination handling.
[Conversion](https://libtmux.org/en/csharp/latest/workspace/cli/convert/) changes file encoding without proving the
document can be loaded.

[CLI source](https://github.com/libtmux/libtmux-dotnet/blob/f77fe776ba67a04abb20ddbbc26cf4a000d63b74/src/LibTmux.Workspace.Cli/README.md).
