# libtmux.Server.confirm_before

- **Module:** libtmux
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/server.py#L1102
- **Page:** https://libtmux.org/en/py/stable/reference/libtmux-server-confirm_before/

tmux command: [`confirm-before`](/en/tmux/latest/manual/confirm-before/)

```
libtmux.Server.confirm_before(
    self,
    command: str,
    prompt: str | None = None,
    confirm_key: str | None = None,
    default_yes: bool | None = None,
    target_client: str | None = None,
) -> None
```

Run a command after confirmation via [`$ tmux confirm-before`](/en/tmux/latest/manual/confirm-before/).

Always uses ``-b`` (background) to avoid blocking the command queue.
Use [`send-keys -K -c <client>`](/en/tmux/latest/manual/send-keys/) to provide the confirmation key.

Requires tmux 3.3+ for ``-b`` flag support.

## Examples

Interactive confirmation requires tmux 3.4+; the wrapper itself works on 3.3+ but the ``send-keys -K -c <client>`` round-trip used here is unreliable on 3.3a:

```python
>>> from libtmux.common import has_gte_version
>>> if has_gte_version("3.4"):
...     with control_mode() as ctl:
...         server.confirm_before(
...             'set -g @cf_test yes',
...             target_client=ctl.client_name,
...         )
...         _ = server.cmd('send-keys', '-K', '-c', ctl.client_name, 'y')
...         result = server.cmd('show-options', '-gv', '@cf_test').stdout[0]
... else:
...     result = 'yes'
>>> result
'yes'
```

## Parameters

- `command` (`str`): Tmux command to run after confirmation.
- `prompt` (`str | None`): Custom prompt text (``-p`` flag).
- `confirm_key` (`str | None`): Key to accept as confirmation (``-c`` flag). Default is ``y``.
Requires tmux 3.4+.
- `default_yes` (`bool | None`): Make Enter default to yes (``-y`` flag). Requires tmux 3.4+.
- `target_client` (`str | None`): Target client (``-t`` flag).

## In other ports

### Ask a client to confirm before running a command

- Go: [`tmux.Server.ConfirmBefore`](/en/go/latest/reference/tmux-server-confirmbefore/) (method)
- C#: [`LibTmux.Server.ConfirmBeforeAsync`](/en/csharp/latest/reference/libtmux-server-confirmbeforeasync/) (method)
