{"id":2099,"library":"libtmux","title":"libtmux","description":"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.","status":"active","version":"0.55.0","language":"en","source_language":"en","source_url":"https://github.com/tmux-python/libtmux","tags":["tmux","terminal","automation","wrapper","cli","scripting"],"install":[{"cmd":"pip install libtmux","lang":"bash","label":"Install libtmux"}],"dependencies":[],"imports":[{"symbol":"Server","correct":"from libtmux import Server"},{"symbol":"Session","correct":"from libtmux import Session"},{"symbol":"Window","correct":"from libtmux import Window"},{"symbol":"Pane","correct":"from libtmux import Pane"}],"quickstart":{"code":"from libtmux import Server\n\n# Connect to the tmux server\nserver = Server()\n\n# Find or create a session named 'my_session'\nsession = server.find_where({\"session_name\": \"my_session\"})\nif session is None:\n    session = server.new_session(session_name=\"my_session\")\n\n# Get the attached window and pane\nwindow = session.attached_window\npane = window.attached_pane\n\n# Send keys to the pane\npane.send_keys(\"echo Hello, libtmux!\", enter=True)\n\n# Print current session name\nprint(f\"Active session: {session.name}\")\n\n# Kill the session (optional, for cleanup)\n# session.kill_session()","lang":"python","description":"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."},"warnings":[{"fix":"Consult the libtmux migration guide (https://libtmux.git-pull.com/migration.html) and update your code to use the modern, recommended API methods.","message":"As of v0.51.0, legacy API methods (deprecated in v0.16–v0.33) now raise `DeprecatedError` instead of just emitting a `DeprecationWarning`. This will cause hard errors if old methods are still in use.","severity":"breaking","affected_versions":">=0.51.0"},{"fix":"Upgrade your tmux installation to version 3.2 or newer to ensure compatibility. Check your tmux version with `tmux -V`.","message":"libtmux versions 0.49.0 and newer have dropped support for tmux versions older than 3.2. If you are running an older tmux version, operations may fail or behave unexpectedly.","severity":"breaking","affected_versions":">=0.49.0"},{"fix":"If your workflow requires the session object to reflect the latest state immediately after `attach()`, manually call `session.refresh()` after `session.attach()` returns.","message":"In v0.53.0, the `Session.attach()` method no longer automatically calls `refresh()` after returning. If your application expects immediate state updates after attaching, you will need to explicitly call `session.refresh()`.","severity":"breaking","affected_versions":">=0.53.0"},{"fix":"Ensure your Python environment is version 3.10, 3.11, or 3.12. Upgrade your Python installation if necessary.","message":"libtmux requires Python 3.10 or newer, but less than Python 4.0. Running on older Python versions (e.g., 3.9) will result in installation or runtime errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}