# libtmux.Server.display_message

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

```
libtmux.Server.display_message(
    self,
    cmd: str,
    get_text: t.Literal[True],
    format_string: str | None = ...,
    all_formats: bool | None = ...,
    verbose: bool | None = ...,
    no_expand: bool | None = ...,
    target_client: str | None = ...,
    delay: int | None = ...,
    notify: bool | None = ...,
) -> list[str]

libtmux.Server.display_message(
    self,
    cmd: str,
    get_text: t.Literal[False] = ...,
    format_string: str | None = ...,
    all_formats: bool | None = ...,
    verbose: bool | None = ...,
    no_expand: bool | None = ...,
    target_client: str | None = ...,
    delay: int | None = ...,
    notify: bool | None = ...,
) -> None

libtmux.Server.display_message(
    self,
    cmd: str,
    get_text: bool = False,
    format_string: str | None = None,
    all_formats: bool | None = None,
    verbose: bool | None = None,
    no_expand: bool | None = None,
    target_client: str | None = None,
    delay: int | None = None,
    notify: bool | None = None,
) -> list[str] | None
```

Display message at server scope via [`$ tmux display-message`](/en/tmux/latest/manual/display-message/).

Like :meth:`Pane.display_message` but without ``-t <pane-id>`` injection.
tmux's ``cmd-display-message`` entry uses ``CMD_FIND_CANFAIL`` so the
target is optional; server-scoped format reads ([`#{version}`](/en/tmux/latest/catalog/formats/version/),
[`#{socket_path}`](/en/tmux/latest/catalog/formats/socket_path/), [`#{pid}`](/en/tmux/latest/catalog/formats/pid/)) resolve without a specific pane handle.

With no client attached and ``target_client`` omitted, the status-line
path (``get_text=False``) issues a ``no current client`` warning. Use
``get_text=True`` for headless reads, or pair with
:class:`~libtmux._internal.control_mode.ControlMode`.

### Notes

Stderr from tmux is reported via :func:`warnings.warn`, not raised.
tmux uses stderr for both genuine errors and informational messages,
and the right escalation depends on tmux version and call shape.
Callers that want to escalate to an exception can wrap the call in
:func:`warnings.catch_warnings` with ``filterwarnings("error")``.

## Examples

Read tmux version without needing a pane handle:

```python
>>> result = server.display_message("#{version}", get_text=True)
>>> isinstance(result, list) and len(result) == 1
True
```

Dump every format variable:

```python
>>> result = server.display_message("", get_text=True, all_formats=True)
>>> any("session_name=" in line for line in result)
True
```

## Changed

0.57 — Reports stderr via :func:`warnings.warn` instead of raising.

## Parameters

- `cmd` (`str`): Format string to display or evaluate (e.g. ``"#{version}"``).
Pass ``""`` together with ``all_formats=True`` to dump every
variable. (added 0.57)
- `get_text` (`bool`): Return tmux's stdout instead of rendering to the status line
(``-p`` flag). (added 0.57)
- `format_string` (`str | None`): Alternative format template (``-F`` flag). (added 0.57)
- `all_formats` (`bool | None`): List all format variables (``-a`` flag). (added 0.57)
- `verbose` (`bool | None`): Show format variable types (``-v`` flag). (added 0.57)
- `no_expand` (`bool | None`): Output the literal string without format expansion (``-l`` flag).
Requires tmux 3.4+. (added 0.57)
- `target_client` (`str | None`): Target client (``-c`` flag). (added 0.57)
- `delay` (`int | None`): Display time in milliseconds (``-d`` flag). (added 0.57)
- `notify` (`bool | None`): Do not wait for input (``-N`` flag). (added 0.57)

## Returns

list[str] | None
    Message output if ``get_text`` is True, otherwise ``None``.

## In other ports

### Show a message on a client

- Go: [`tmux.Server.DisplayMessage`](/en/go/latest/reference/tmux-server-displaymessage/) (method)
- C#: [`LibTmux.Server.DisplayMessageAsync`](/en/csharp/latest/reference/libtmux-server-displaymessageasync/) (method)
- C++: [`libtmux::Server::show_message`](/en/cxx/latest/reference/libtmux-server-show_message/) (method)
