# freeze.freeze

- **Module:** freeze
- **Package:** tmux-workspace
- **Language:** Rust
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/tmux-workspace/src/freeze.rs#L64
- **Page:** https://libtmux.org/en/rs/latest/workspace/reference/freeze-freeze/

```
freeze.freeze(session: &Session) -> Result<Workspace, Error>
```

Describe a live session as a workspace.

The result is a [`Workspace`], so it can be rendered with
[`Workspace::to_yaml`] or handed straight back to
[`crate::WorkspaceBuilder`] to make another like it.

A pane is described by the command tmux says it is running, by name and
without its arguments. A pane at its shell's prompt freezes to a pane
with no command: tmux reports the shell itself, and recording it would
start a shell inside a shell when the file is built. A shell is the
session's `default-shell`, or a common interactive shell by name.

# Errors

Returns an error when the session's windows or panes cannot be listed.

## Example

```rust
use libtmux::{SplitDirection, SplitOptions};
use tmux_workspace::freeze;

let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("built-by-hand").await?;
let mut window = session.active_window().await?.expect("a window");
window.split(SplitOptions::new(SplitDirection::Below)).await?;

let workspace = freeze(&session).await?;

assert_eq!(workspace.session_name, "built-by-hand");
assert_eq!(workspace.windows.len(), 1);
assert_eq!(workspace.windows[0].panes.len(), 2);

// And it round-trips through the file format.
let yaml = workspace.to_yaml();
assert_eq!(tmux_workspace::Workspace::from_yaml(&yaml)?, workspace);

guard.shutdown().await?;
```
