# tmux display-menu

Source: https://libtmux.org/en/tmux/latest/manual/display-menu/

> Display a menu on target-client.

Display a menu on target-client.

## Syntax

```tmux-usage
tmux display-menu [-MO] [-b border-lines] [-c target-client] [-C starting-choice] [-H selected-style] [-s style] [-S border-style] [-t target-pane] [-T title] [-x position] [-y position] name [key] [command] ...
```

Alias: `menu`.

## Behavior

Display a menu on `target-client`. `target-pane` gives the target for any commands run from the menu.

A menu is passed as a series of arguments: first the menu item name, second the key shortcut (or empty for none) and third the command to run when the menu item is chosen. The name and command are formats, see the [FORMATS](https://libtmux.org/en/tmux/latest/manual/full/#FORMATS) and [STYLES](https://libtmux.org/en/tmux/latest/manual/full/#STYLES) sections. If the name begins with a hyphen (-), then the item is disabled (shown dim) and may not be chosen. The name may be empty for a separator line, in which case both the key and command should be omitted.

`-b` sets the type of characters used for drawing menu borders. See `popup-border-lines` for possible values for `border-lines`.

`-H` sets the style for the selected menu item (see [STYLES](https://libtmux.org/en/tmux/latest/manual/full/#STYLES)).

`-s` sets the style for the menu and `-S` sets the style for the menu border (see [STYLES](https://libtmux.org/en/tmux/latest/manual/full/#STYLES)).

`-T` is a format for the menu title (see [FORMATS](https://libtmux.org/en/tmux/latest/manual/full/#FORMATS)).

`-C` sets the menu item selected by default, if the menu is not bound to a mouse key binding.

`-x` and `-y` give the position of the menu. Both may be a row or column number, or one of the following special values:

|                                                                    |                                                                  |                                                                          |
| ------------------------------------------------------------------ | ---------------------------------------------------------------- | ------------------------------------------------------------------------ |
| [**Value**](https://libtmux.org/en/tmux/latest/manual/full/#Value) | [**Flag**](https://libtmux.org/en/tmux/latest/manual/full/#Flag) | [**Meaning**](https://libtmux.org/en/tmux/latest/manual/full/#Meaning~4) |
| [`C`](https://libtmux.org/en/tmux/latest/manual/full/#C~2)         | Both                                                             | The centre of the terminal                                               |
| [`R`](https://libtmux.org/en/tmux/latest/manual/full/#R)           | [`-x`](https://libtmux.org/en/tmux/latest/manual/full/#x~3)      | The right side of the terminal                                           |
| [`P`](https://libtmux.org/en/tmux/latest/manual/full/#P)           | Both                                                             | The bottom left of the pane                                              |
| [`M`](https://libtmux.org/en/tmux/latest/manual/full/#M~3)         | Both                                                             | The mouse position                                                       |
| [`W`](https://libtmux.org/en/tmux/latest/manual/full/#W)           | Both                                                             | The window position on the status line                                   |
| [`S`](https://libtmux.org/en/tmux/latest/manual/full/#S~3)         | [`-y`](https://libtmux.org/en/tmux/latest/manual/full/#y)        | The line above or below the status line                                  |

Or a format, which is expanded including the following additional variables:

|                                                                                                            |                                                                                 |
| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| [**Variable name**](https://libtmux.org/en/tmux/latest/manual/full/#Variable~2)                            | [**Replaced with**](https://libtmux.org/en/tmux/latest/manual/full/#Replaced~2) |
| [`popup_centre_x`](https://libtmux.org/en/tmux/latest/manual/full/#popup_centre_x)                         | Centered in the client                                                          |
| [`popup_centre_y`](https://libtmux.org/en/tmux/latest/manual/full/#popup_centre_y)                         | Centered in the client                                                          |
| [`popup_height`](https://libtmux.org/en/tmux/latest/manual/full/#popup_height)                             | Height of menu or popup                                                         |
| [`popup_mouse_bottom`](https://libtmux.org/en/tmux/latest/manual/full/#popup_mouse_bottom)                 | Bottom of at the mouse                                                          |
| [`popup_mouse_centre_x`](https://libtmux.org/en/tmux/latest/manual/full/#popup_mouse_centre_x)             | Horizontal centre at the mouse                                                  |
| [`popup_mouse_centre_y`](https://libtmux.org/en/tmux/latest/manual/full/#popup_mouse_centre_y)             | Vertical centre at the mouse                                                    |
| [`popup_mouse_top`](https://libtmux.org/en/tmux/latest/manual/full/#popup_mouse_top)                       | Top at the mouse                                                                |
| [`popup_mouse_x`](https://libtmux.org/en/tmux/latest/manual/full/#popup_mouse_x)                           | Mouse X position                                                                |
| [`popup_mouse_y`](https://libtmux.org/en/tmux/latest/manual/full/#popup_mouse_y)                           | Mouse Y position                                                                |
| [`popup_pane_bottom`](https://libtmux.org/en/tmux/latest/manual/full/#popup_pane_bottom)                   | Bottom of the pane                                                              |
| [`popup_pane_left`](https://libtmux.org/en/tmux/latest/manual/full/#popup_pane_left)                       | Left of the pane                                                                |
| [`popup_pane_right`](https://libtmux.org/en/tmux/latest/manual/full/#popup_pane_right)                     | Right of the pane                                                               |
| [`popup_pane_top`](https://libtmux.org/en/tmux/latest/manual/full/#popup_pane_top)                         | Top of the pane                                                                 |
| [`popup_status_line_y`](https://libtmux.org/en/tmux/latest/manual/full/#popup_status_line_y)               | Above or below the status line                                                  |
| [`popup_width`](https://libtmux.org/en/tmux/latest/manual/full/#popup_width)                               | Width of menu or popup                                                          |
| [`popup_window_status_line_x`](https://libtmux.org/en/tmux/latest/manual/full/#popup_window_status_line_x) | At the window position in status line                                           |
| [`popup_window_status_line_y`](https://libtmux.org/en/tmux/latest/manual/full/#popup_window_status_line_y) | At the status line showing the window                                           |

Each menu consists of items followed by a key shortcut shown in brackets. If the menu is too large to fit on the terminal, it is not displayed. Pressing the key shortcut chooses the corresponding item. If the mouse is enabled and the menu is opened from a mouse key binding, releasing the mouse button with an item selected chooses that item and releasing the mouse button without an item selected closes the menu. `-O` changes this behaviour so that the menu does not close when the mouse button is released without an item selected the menu is not closed and a mouse button must be clicked to choose an item.

`-M` tells `tmux` the menu should handle mouse events; by default only menus opened from mouse key bindings do so.

The following keys are available in menus:

|                                                                    |                                                                            |
| ------------------------------------------------------------------ | -------------------------------------------------------------------------- |
| [**Key**](https://libtmux.org/en/tmux/latest/manual/full/#Key~4)   | [**Function**](https://libtmux.org/en/tmux/latest/manual/full/#Function~5) |
| [`Enter`](https://libtmux.org/en/tmux/latest/manual/full/#Enter~4) | Choose selected item                                                       |
| [`Up`](https://libtmux.org/en/tmux/latest/manual/full/#Up~4)       | Select previous item                                                       |
| [`Down`](https://libtmux.org/en/tmux/latest/manual/full/#Down~4)   | Select next item                                                           |
| [`q`](https://libtmux.org/en/tmux/latest/manual/full/#q~4)         | Exit menu                                                                  |

## C implementation

Internal declarations in tmux 3.7c:

* [`cmd_display_menu_entry`](https://libtmux.org/en/tmux/latest/reference/c-variable-cmd_display_menu_entry/)
* [`cmd_display_menu_exec`](https://libtmux.org/en/tmux/latest/reference/c-function-cmd-display-menu-c-cmd_display_menu_exec/)

## Use from a library

Each API describes its own defaults, errors and execution model.

* [Python](https://libtmux.org/en/py/latest/reference/libtmux-server-display_menu/)
* [Rust](https://libtmux.org/en/rs/latest/reference/server-server-display_menu/)
* [Go](https://libtmux.org/en/go/latest/reference/tmux-server-displaymenu/)

tmux sources and license

Syntax comes from `tmux 3.7c list-commands`. See the [global options](https://libtmux.org/en/tmux/latest/manual/full/#DESCRIPTION) for sockets and configuration, and [command syntax and targets](https://libtmux.org/en/tmux/latest/manual/full/#COMMANDS).

Behavior is taken from the [tmux 3.7c manual](https://github.com/tmux/tmux/blob/79072dd1a9f5fb437a5859e362a496fd57ec0981/tmux.1).

[Command declaration](https://github.com/tmux/tmux/blob/79072dd1a9f5fb437a5859e362a496fd57ec0981/cmd-display-menu.c#L38)

```
Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
```
