tmuxp

1.67.0 · active · verified Thu Apr 16

tmuxp is an active and frequently updated Python session manager for tmux, enabling users to save, load, and manage complex tmux sessions and workspaces via simple YAML or JSON configuration files. It is built upon the `libtmux` Python API for programmatic interaction with tmux.

Common errors

Warnings

Install

Imports

Quickstart

Create a YAML configuration file to define a tmux session, then load it using the `tmuxp load` CLI command. Configuration files are typically stored in `~/.tmuxp/` or within project directories (e.g., `.tmuxp.yaml`).

import os

# Create a sample tmuxp configuration file
config_content = """
session_name: my_dev_session
windows:
  - window_name: dev
    layout: main-vertical
    panes:
      - shell_command: echo 'Hello from pane 1!'
      - shell_command: echo 'Hello from pane 2!'
  - window_name: logs
    panes:
      - shell_command: tail -f /var/log/syslog
"""

config_dir = os.path.expanduser("~/.tmuxp")
os.makedirs(config_dir, exist_ok=True)
config_path = os.path.join(config_dir, "my_dev_session.yaml")

with open(config_path, "w") as f:
    f.write(config_content)

print(f"Config saved to: {config_path}")
print("To load this session, run: tmuxp load my_dev_session")
print("Or, from the directory containing the file: tmuxp load ./my_dev_session.yaml")

view raw JSON →