libtmux
Typed library that provides an ORM wrapper for tmux, a terminal multiplexer.
What it is and what it does
libtmux is a typed Python wrapper around tmux that replaces shell command parsing with real object-oriented control. Instead of running `tmux ls` and parsing output, you work with `Server`, `Session`, `Window`, and `Pane` objects that reflect live tmux state. The library supports querying and filtering collections, traversing the hierarchy (pane → window → session), sending keystrokes to panes, and capturing output—all with full type hints.
The package is battle-tested in production through tmuxp (a declarative workspace manager built on top of it) and includes a pytest plugin for writing isolated tmux tests. It also supports context managers for cleanup, multiple tmux sockets, and a `.cmd()` escape hatch for raw tmux commands when needed. Code running inside a tmux pane can use `from_env()` to locate itself in the hierarchy.
Use it for:
- Automate tmux session setup and teardown in deployment or development scripts without shell parsing.
- Write pytest tests for tools that interact with tmux, using isolated fixtures for each test.
- Build terminal UI tools or dashboards that need to query and control live tmux state programmatically.
- Capture pane output and send commands to tmux from Python applications or background agents.
- Implement tmux-based workflow orchestration (e.g., spawning parallel tasks in separate panes).
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
libtmux provides a typed Python API to control tmux (the terminal multiplexer) programmatically, letting you manage servers, sessions, windows, and panes as Python objects instead of parsing shell commands.
Yes. libtmux is actively maintained, has no external dependencies, supports current Python versions (3.10–3.14, PyPy), and solves a real problem for anyone automating tmux or testing tmux-aware tools. The MIT license imposes no restrictions. Start with a pinned version range (e.g., `libtmux==0.62.*`) since the package is pre-1.0.
Install
libtmux on PyPI
pip
pip install libtmuxuv
uv add libtmuxpoetry
poetry add libtmuxInstalling libtmux
Before you install
Low friction: pure Python wheel with no runtime dependencies. Active maintenance (last commit 2026-08-13, release 33 days ago). Requires tmux >= 3.2a and Python >= 3.10; older versions available on maintenance branches for Python 2.x and tmux 1.8–3.1c.
License in practice
MIT license (permissive). No restrictions on commercial or proprietary use; attribution appreciated but not required.
Quickstart
pip install libtmux
import libtmux
server = libtmux.Server()
session = server.sessions.get(session_name="my-session")
window = session.new_window(window_name="work")
pane = window.active_pane
pane.send_keys("echo hello", enter=True)
tmux >= 3.2a must be installed on the system; Python >= 3.10 required.
Verify before relying
- Whether the pytest plugin is automatically available or requires separate installation.
- Performance characteristics when managing many sessions/windows/panes concurrently.
- Compatibility with tmux forks or non-standard tmux builds.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 33 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 13,140,422/month — #1,294 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: libtmux-0.62.0-py3-none-any.whl
Keywords: ncurses, session manager, terminal, tmux
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pairmuxpairmux lets AI agents control interactive…
permissive · top 15,000 on PyPI
tmuxptmuxp saves and loads tmux sessions from YAML…
permissive · top 15,000 on PyPI
imgcatDisplays images in iTerm2, WezTerm, and tmux by…
permissive · top 15,000 on PyPI
iterm2Provides a Python scripting interface to…
copyleft · top 15,000 on PyPI
ptpythonptpython is an advanced interactive Python…
permissive · top 5,000 on PyPI
ms-fabric-cliA command-line interface for Microsoft Fabric…
unclear · top 15,000 on PyPI
textual-imageRenders images directly in terminal emulators…
copyleft · top 15,000 on PyPI
ptyprocessRun a subprocess in a pseudo terminal (pty) and…
permissive · top 1,000 on PyPI
browser-use-coreProvides packaged Rust terminal binaries and…
unclear · top 15,000 on PyPI
coloramaColorama makes ANSI escape sequences for…
permissive · top 100 on PyPI