Skip to main content

pmenu

Sleek dmenu alternative written in Python and powered by curses.

pip install pmenu-lib


Button Hover Button Hover



This package provides both a command-line tool and a Python library for creating interactive terminal menus.

Usage

Library Usage

The pmenu(list_of_options) function displays a menu and returns the selected option as a str, or None if the menu is closed without selecting an option.

from pmenu_lib import pmenu

options = ["Option 1", "Option 2", "Option 3"]
selected_option = pmenu(options)

if selected_option:
    print(f"You selected: {selected_option}")
else:
    print("No option selected")

CLI Usage

After installation, you can use pmenu from the command line:

pmenu "line1\nline2\nline3..."

Or pass multiple arguments:

pmenu "option1" "option2" "option3"

The selected option will be written to /tmp/pmenu (or equivalent temp directory on Windows).

Exit Codes

  • 0: Option selected successfully
  • 1: Menu closed without selection (ESC pressed)
  • 2: Invalid usage (no arguments provided)

Menu Bindings

  • Up arrow: Highlight the previous menu entry
  • Down arrow: Highlight the next menu entry
  • Type to search: Filter options in real-time
  • Backspace: Delete search characters
  • Enter: Select the highlighted entry
  • Esc: Close the menu without selecting

pmenu_fm: A Practical Use Case (Linux)

The pmenu_fm script included in this repository is an example of how pmenu can be integrated into a bash script to implement a simple file selector.

It uses lsd, a modern ls replacement, to get the list of files in the current directory and their associated icons. The list is then passed to pmenu, which displays a menu in the terminal window.

You can highlight a directory with the Up and Down keys, and change to the selected directory or xdg-open the selected file with the Enter key. The menu can be closed with the Esc key.

Release files for pmenu-lib 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pmenu-lib 1.2.2
File Size Uploaded
pmenu_lib-1.2.2.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pmenu-lib 1.2.2
File Interpreter ABI Platform
pmenu_lib-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 24.6 kB

Release files / pmenu_lib-1.2.2.tar.gz

Download URL pmenu_lib-1.2.2.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
77faadeb864c302c18153265062819e2c97781cc7de996b8c1e53500c0d58a90
BLAKE2b-256 checksum
How to use checksums
5ebbb4fc840085952613c35d3c8449a30ea0576436eeca201651d72c7d9d2ec1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.5

Release files / pmenu_lib-1.2.2-py3-none-any.whl

Download URL pmenu_lib-1.2.2-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a0b34d3fc2881193e035f983d9c38285bcaeb131e884e0a01ba4ffc0b810ee4
BLAKE2b-256 checksum
How to use checksums
7e771b73bd2f7968678732c49d74b7a2e35bc2ea7f8c8483eddc904adab31b19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.5

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.9.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page