# LibTmuxWorkspace.apply

- **Module:** LibTmuxWorkspace
- **Package:** LibTmuxWorkspace
- **Language:** Julia
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-julia/blob/f3da513be1225d36d5854cd8db5972c01857578e/packages/LibTmuxWorkspace/src/apply.jl#L193
- **Page:** https://libtmux.org/en/julia/latest/workspace/reference/libtmuxworkspace-apply/

```
apply(
    server::LibTmux.Server,
    prepared::LibTmuxWorkspace.WorkspacePlan;
    timeout,
    cancel,
    reuse,
    rollback,
    readiness,
    script_env,
    on_event
)
```

## Methods

Apply detached through public core operations under one monotonic deadline. Existing names fail by default. `reuse=SessionRef(...)` explicitly borrows that exact session after checking its generation and name. Only newly created panes receive commands. The plan's 1-based positions resolve to returned typed refs.

```julia
apply(server, plan; timeout=30.0, cancel=nothing, reuse=nothing,
      rollback=:none, readiness=:posix_shell, script_env=ENV, on_event=nothing)
```



Default readiness sends a marker through a POSIX shell and awaits its atomic publication through an owned file monitor. No polling or delays occur. Cancellation removes the directory, so late producers cannot leave waiters. Custom launchers with input require explicit `readiness=:none`. A successful command step means input was delivered, not that its shell job finished or succeeded.

`rollback=:created` attempts uncancelled cleanup within 900 ms: remove the new session, or only created window links in a borrowed session. It does not restore borrowed options/environment, global settings or shell effects. Failed/uncertain creations are never guessed at or deleted. Inspect `WorkspaceApplyError.result`. Events run synchronously and must return promptly; a callback error stops apply.

## Parameters

- `server` (`LibTmux.Server`)
- `prepared` (`LibTmuxWorkspace.WorkspacePlan`)
- `timeout` (`Real`)
  Default: `30.0`.
- `cancel`
  Default: `nothing`.
- `reuse` (`Union{Nothing, LibTmux.SessionRef}`)
  Default: `nothing`.
- `rollback` (`Symbol`)
  Default: `:none`.
- `readiness` (`Symbol`)
  Default: `:posix_shell`.
- `script_env` (`AbstractDict`)
  Default: `ENV`.
- `on_event`
  Default: `nothing`.

## In other ports

### Build a session from a workspace description

- PowerShell: [`LibTmux.Workspace\Invoke-TmuxWorkspace`](/en/powershell/latest/workspace/reference/libtmux-workspace-invoke-tmuxworkspace/) (cmdlet). Applies the exact reviewed [`-Plan`](/en/powershell/latest/workspace/reference/libtmux-workspace-invoke-tmuxworkspace/#LibTmux.Workspace%5CInvoke-TmuxWorkspace.parameter.Plan) after PowerShell confirmation. [`-WhatIf`](/en/powershell/latest/workspace/reference/libtmux-workspace-invoke-tmuxworkspace/#LibTmux.Workspace%5CInvoke-TmuxWorkspace.parameter.WhatIf) previews without applying it; application is detached.
- Python: [`tmuxp.workspace.builder.ClassicWorkspaceBuilder.build`](/en/py/latest/workspace/reference/tmuxp-workspace-builder-classicworkspacebuilder-build/) (method)
- Ruby: [`LibTmux::Workspace::Plan#apply`](/en/ruby/latest/workspace/reference/libtmux-workspace-plan-apply/) (method)
- TypeScript: [`builder.applyWorkspace`](/en/ts/latest/workspace/reference/builder-applyworkspace/) (function)
- Rust: [`src.WorkspaceBuilder.build`](/en/rs/latest/workspace/reference/src-workspacebuilder-build/) (method)
- Go: [`workspace.Build`](/en/go/latest/workspace/reference/workspace-build/) (function)
- Java: [`io.github.libtmux.workspace.WorkspaceBuilder.WorkspaceBuilder.build`](/en/java/latest/workspace/reference/io-github-libtmux-workspace-workspacebuilder-workspacebuilder-build/) (method)
- C#: [`LibTmux.Workspace.WorkspaceBuilder.BuildAsync`](/en/csharp/latest/workspace/reference/libtmux-workspace-workspacebuilder-buildasync/) (method)
- C++: [`libtmux::workspace::build`](/en/cxx/latest/workspace/reference/libtmux-workspace-build/) (function)
- Swift: [`WorkspaceBuilder.build(_:on:)`](/en/swift/latest/workspace/reference/workspacebuilder-build(_-on-)/) (method)
