# tmux_option:set/4

- **Package:** libtmux_erlang
- **Language:** Erlang
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-erlang/blob/d1b6308440cf9eb8f6647e7ae434bce60e849368/apps/libtmux_erlang/src/tmux_option.erl#L178
- **Page:** https://libtmux.org/en/erlang/latest/reference/tmux_option-set-4/

```
set(Scope, Key, Value, Options)
-spec set(scope(), key(), binary(), write_options()) ->
             {ok, tmux_operation:completed()} |
             {error, tmux_operation:failure()}.
```

Set a literal binary value, after scope/version/owner validation. Array writes require {Name, Index}; this avoids tmux's whole-array separator grammar. append uses tmux's type-specific -a semantics. only_if_unset checks the local table; already-set is a backend error, with no suppressed errors or compare-and-swap guarantee. Values must be supplied explicitly; an empty flag value retains tmux's native toggle behavior. A successful result proves command completion, not later effects of a stored command or format. Performs I/O; never retries.

## Parameters

- `Scope` (`scope()`)
- `Key` (`key()`)
- `Value` (`binary()`)
- `Options` (`write_options()`)

## tmux command

The tmux commands behind `set/4`.

- [`set-option`](/en/tmux/latest/manual/set-option/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_set_option_entry`](/en/tmux/latest/reference/c-variable-cmd_set_option_entry/) (attribute)
- [`cmd_set_option_exec`](/en/tmux/latest/reference/c-function-cmd-set-option-c-cmd_set_option_exec/) (function)
