libtmux is a typed Python library providing an ORM (Object-Relational Mapper) wrapper for tmux, the terminal multiplexer. It allows programmatic control over tmux servers, sessions, windows, and panes. The current version is 0.55.0, and it maintains an active release cadence with frequent updates and bug fixes.
pip install libtmuxVerified import paths — ran on the pinned version, not inferred.
Demonstrates connecting to the tmux server, finding or creating a session, accessing its attached window and pane, and sending commands to the pane. The example includes optional session cleanup.
Consult the libtmux migration guide (https://libtmux.git-pull.com/migration.html) and update your code to use the modern, recommended API methods.
Upgrade your tmux installation to version 3.2 or newer to ensure compatibility. Check your tmux version with `tmux -V`.
If your workflow requires the session object to reflect the latest state immediately after `attach()`, manually call `session.refresh()` after `session.attach()` returns.
Ensure your Python environment is version 3.10, 3.11, or 3.12. Upgrade your Python installation if necessary.
Install the library using pip: `pip install libtmux`
Install tmux on your operating system (e.g., `sudo apt-get install tmux` on Debian/Ubuntu, `brew install tmux` on macOS).
Ensure a tmux server is running by manually starting a session (e.g., `tmux new -s my_session`) before executing the Python script. If the error persists, check for and remove stale tmux socket files, typically found in `/tmp/tmux-*`.
Verify the target session, window, or pane exists (e.g., using `tmux ls` or by inspecting `server.sessions`). Ensure the libtmux objects are refreshed to reflect the current tmux state (e.g., `server.sessions.refresh()`). For locale issues, set the `LANG` environment variable correctly (e.g., `export LANG=en_US.UTF-8`).
Ensure the tmux session is attached to a client with adequate screen dimensions. Alternatively, configure tmux with larger default window/pane sizes, or use libtmux methods to explicitly set pane/window sizes and layouts (e.g., `window.select_layout('even-horizontal')`) after splitting.No dependency data recorded yet.