Skip to main content

Composable tmux popup system with gum UI components

Project description

tmux-popup

Composable tmux popup system with gum UI components.

tmux-popup demo
Interactive popup components in action

✨ Features

  • 🎨 Rich Components - Styled text, inputs, selections, confirmations
  • 🔧 Composable API - Chain commands for complex interactions
  • 📦 Zero Dependencies - Pure Python, only needs tmux and gum
  • 🎯 Type-Safe - Full type hints and result parsing
  • 🚀 Lightweight - Simple, focused library

📋 Prerequisites

Required system tools:

  • tmux - Terminal multiplexer for popups
  • gum - Provides the UI components
# macOS
brew install tmux gum

# Arch Linux
sudo pacman -S tmux gum

# Ubuntu/Debian
sudo apt install tmux
# For gum: https://github.com/charmbracelet/gum#installation

📦 Installation

# Install from PyPI (coming soon)
uv add tmux-popup                  # Recommended
pip install tmux-popup             # Alternative

# Install from source
uv add git+https://github.com/angelsen/tap-tools.git#subdirectory=packages/tmux-popup
# Or with pip:
pip install git+https://github.com/angelsen/tap-tools.git#subdirectory=packages/tmux-popup

🚀 Quick Start

from tmux_popup import Popup
from tmux_popup.gum import GumStyle, GumInput, GumChoose

# Create a simple popup
popup = Popup(width="65", title="My App")
result = popup.add(
    GumStyle("Welcome!", header=True),
    GumInput(placeholder="Enter your name...")
).show()

print(f"Hello, {result}!")

🎮 Usage

Basic Input

popup = Popup(width="50")
name = popup.add(
    GumStyle("User Setup", header=True),
    "Please enter your details:",
    GumInput(placeholder="Name...", value="")
).show()

Confirmations

popup = Popup()
confirmed = popup.add(
    GumStyle("⚠️ Warning", warning=True),
    "This will delete all data.",
    GumConfirm("Are you sure?", default=False)
).show()

if confirmed:
    # Proceed with deletion
    pass

Selections

# Single choice
choice = popup.add(
    GumStyle("Select Action", header=True),
    GumChoose([
        ("new", "📝 New File"),
        ("open", "📂 Open File"),
        ("save", "💾 Save File"),
        ("quit", "❌ Quit")
    ])
).show()

# Multiple selection with fuzzy search
items = ["Python", "JavaScript", "Go", "Rust", "TypeScript"]
selected = popup.add(
    GumStyle("Select Languages", info=True),
    GumFilter(items, limit=0, fuzzy=True)
).show()  # Returns list of selected items

Tables

data = [
    ["Active", "Server 1", "192.168.1.10"],
    ["Idle", "Server 2", "192.168.1.11"],
    ["Active", "Server 3", "192.168.1.12"],
]

selected_ip = popup.add(
    GumStyle("Select Server", header=True),
    GumTable(
        data,
        headers=["Status", "Name", "IP"],
        return_column=2  # Return IP column
    )
).show()

📚 Components

Core

  • Popup - Main popup runner with tmux display-popup
  • Command - Base class for all UI commands

Input Components

  • GumInput - Single line text input
  • GumWrite - Multi-line text editor
  • GumConfirm - Yes/no confirmation

Selection Components

  • GumChoose - Single choice from list
  • GumFilter - Fuzzy search with multi-select
  • GumFile - File picker
  • GumTable - Table with row selection

Display Components

  • GumStyle - Styled text with presets (header, info, warning, error)
  • GumFormat - Markdown/template formatting
  • GumPager - Scrollable text viewer
  • GumLog - Formatted log display

Utility Components

  • GumJoin - Layout multiple elements
  • GumSpin - Loading spinner for async operations

🏗️ Architecture

The library follows a simple pattern:

  1. Commands render themselves to shell script
  2. Popup combines commands and executes via tmux
  3. Results are parsed and returned to Python
# Commands know how to render
cmd = GumInput(value="default")
script_lines = cmd.render()  # Returns list of shell commands

# Popup handles execution
popup = Popup()
result = popup.add(cmd).show()  # Executes and returns parsed result

🛠️ Development

# Clone repository
git clone https://github.com/angelsen/tap-tools
cd tap-tools

# Install for development (recommended)
uv sync
uv run --package tmux-popup python examples/demo.py

# Or with pip:
cd packages/tmux-popup
pip install -e .
python examples/demo.py

📄 License

MIT - see LICENSE for details.

👤 Author

Fredrik Angelsen

🙏 Acknowledgments

Built on top of:

  • tmux - Terminal multiplexer
  • gum - Delightful CLI interactions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tmux_popup-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tmux_popup-0.1.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file tmux_popup-0.1.0.tar.gz.

File metadata

  • Download URL: tmux_popup-0.1.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.8

File hashes

Hashes for tmux_popup-0.1.0.tar.gz
Algorithm Hash digest
SHA256 02e0377c2c770edbcf6f59c10f2ba2047bca05422e4386897cdb05d456c9e640
MD5 fbc1fdaca50fbb3e30e6fd0d6b8c8ac9
BLAKE2b-256 20c17c5b7b869a5faccf60b264ca00fba7cc5517daf03c850972ac8f16eda473

See more details on using hashes here.

File details

Details for the file tmux_popup-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tmux_popup-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.8

File hashes

Hashes for tmux_popup-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a68d4a0b70315183420723537a2b483b24cb95ef64c06b996d7898042592040f
MD5 a9b23f35e091af496ae9787bdc7665a7
BLAKE2b-256 44c7f59ea21aab27d7144034e8b96318df9052417b815c9c5bf06b3b9f8a5e4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page