simple-term-menu is a Python package that facilitates the creation of interactive command-line menus. It enables users to select options using arrow keys, j/k (Vim motions), or emacs keys. The library intelligently adapts to terminal capabilities by leveraging the terminfo database, disabling unavailable styles. It is actively maintained, with frequent minor releases, and primarily supports Linux and macOS environments.
pip install simple-term-menuVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic terminal menu with a list of options. The `TerminalMenu` class is instantiated with the options, and the `show()` method displays the menu and returns the index of the selected item or `None` if cancelled.
Update `TerminalMenu` constructor calls to use keyword arguments for all parameters except the initial list of options.
Rename `multi_select_key` to `multi_select_keys` and pass an iterable. Rename `shortcut_parentheses_highlight_style` to `shortcut_brackets_highlight_style`.
Consider alternative libraries for Windows-specific CLI menus or ensure a compatible terminal environment (e.g., WSL) is used.
Refactor menu handling by using classes, dictionaries mapping options to functions, or other structured approaches to keep the code DRY and maintainable.
pip install simple-term-menu
Ensure your TERM environment variable is set correctly (e.g., `xterm`, `screen`), or run the script in a more feature-rich terminal emulator. For Windows, consider using WSL or a compatible terminal.
Wrap the single string (or multiple strings) in a list: `SimpleTermMenu(menu_entries=['Option 1', 'Option 2'])`
Use the correct method name `show()`: `selected_entry = menu.show()`
Use the correct parameter names as specified in the library's documentation, such as `title`, `menu_cursor`, or `cycle_cursor`.
No dependency data recorded yet.