# LibTmux.Action

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** module
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/lib/libtmux/action.ex#L1
- **Page:** https://libtmux.org/en/elixir/pr-173/reference/libtmux-action/

Shared results for explicit pane, window and session actions.

Pass a `LibTmux.Server` for one-shot execution or a `LibTmux.Control` for
managed execution in its qualified connection. No action changes transport,
replays a mutation or refreshes an observation. Targeted one-shot actions
check the server incarnation with an unaliased native [`list-commands`](/en/tmux/latest/manual/list-commands/) read.
The check leaves a check/use race. Hooks on the requested action still run.

Ordinary actions return `{:ok, result}` only for completed commands.
Failed, skipped and unknown outcomes return
`{:error, %LibTmux.Action.CompletionError{result: original_result}}`.
`value` holds the completed command's value; `details` retains the
transport's original bounded evidence. Domain bang functions return the
completed value or raise `LibTmux.Action.CompletionError` with the original
unsuccessful result. Acknowledgement does not prove that a program
processed input or finished running.

API errors use `LibTmux.Error`; admitted control errors preserve the recovery
handle in `LibTmux.Control.ExecutionError`. Domain bang functions raise
these errors unchanged. Lower-level `LibTmux.Control` and `LibTmux.Operation`
bang functions retain canonical outcomes as values.

Action errors with kind `:invalid_command` include a validation `path` such
as `[:options, :size]` and a bounded `details.reason` describing accepted
inputs. The reason appears in the exception message; rejected values are
not retained in diagnostic details. Targeted one-shot actions validate both
native process specifications before the identity read. Session creation
has no observed target; it validates its command and runs without an identity
read. Native byte/count refusals use paths such as `[:process, :argv]` or
`[:process, :frame]`.
Preparation does not check filesystem existence or guarantee execution.

A nonzero one-shot client exit reports `:failed` with `:observed` certainty:
its exit status is observed, not an authenticated tmux command reply or
proof that no effects occurred.

Kill actions run one-shot only: a Control connection returns
`unsupported_transport` before any I/O, because it cannot kill what it is
attached to. A kill command prints nothing, so a completed result has the
value `:ok`.

Optional session context checks physical membership at tmux's command
resolution. It does not bind a particular WindowLink index when a window
has multiple links in that session. `LibTmux.WindowLink.unlink/3` acts on one
captured binding.
See `LibTmux.Pane.split/3`, `LibTmux.Pane.send_text/4` and
`LibTmux.Window.rename/4` for caller examples.

## Members

### Other members

- [`connection/0`](/en/elixir/pr-173/reference/libtmux-action-connection-0/) (typealias): Explicitly selected one-shot descriptor or pinned qualified connection.
- [`creation_option/0`](/en/elixir/pr-173/reference/libtmux-action-creation_option-0/) (typealias): Detached creation on an existing server; default command/shell and directory unless supplied.
- [`creation_value/0`](/en/elixir/pr-173/reference/libtmux-action-creation_value-0/) (typealias): A created native ID without a bound reference; capture a new observation before another targeted action.
- [`error/0`](/en/elixir/pr-173/reference/libtmux-action-error-0/) (typealias): An API refusal, unsuccessful outcome or managed execution error retaining recovery context.
- [`membership_option/0`](/en/elixir/pr-173/reference/libtmux-action-membership_option-0/) (typealias): One deadline for an exact window membership action.
- [`option/0`](/en/elixir/pr-173/reference/libtmux-action-option-0/) (typealias): A 1..600000ms execution budget, default 5000ms; optional exact session context for physical targets.
- [`resize_option/0`](/en/elixir/pr-173/reference/libtmux-action-resize_option-0/) (typealias): Absolute cell dimensions for a pane or window resize. Supply a width, a height or both.
- [`result/1`](/en/elixir/pr-173/reference/libtmux-action-result-1/) (typealias): A completed action's value and original transport evidence.
- [`unsuccessful_result/0`](/en/elixir/pr-173/reference/libtmux-action-unsuccessful_result-0/) (typealias): A failed, skipped or unknown action outcome retained inside CompletionError.
