AgentCreate the session.
Result
{ "session_id": "$0", "session_name": "checks", "window_count": 1, "session_attached": "0", "session_created": "1795059312", "active_pane_id": "%0"}Choose documentation 3
No matching documentation.
No matching versions.
Current version
latestNo matching languages.
Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.
Python-based tmux client
tmux client library for Python. Control tmux, connect to and create servers, navigate sessions, windows, and panes, send keys, watch for changes via control mode, capture pane contents
Control tmux from Python code 0.x Released; the API may change. Read more Core Library home →
from __future__ import annotations
from pathlib import Pathimport tempfileimport time
import libtmuxfrom libtmux.constants import PaneDirection
directory = Path(tempfile.mkdtemp(prefix="libtmux-py-home-"))socket = directory / "tmux.sock"server = libtmux.Server(socket_path=socket, config_file="/dev/null")
session = server.new_session(session_name="demo")
# Lay out the session: name its window, split it, add a second window.editor = session.active_windoweditor.rename_window("editor")left = editor.active_paneassert left is not Noneright = left.split(direction=PaneDirection.Right, shell="sh")logs = session.new_window(window_name="logs")
# Type a command into the new pane and wait for what it prints.right.send_keys("printf 'hello from %s\\n' tmux", enter=True)deadline = time.monotonic() + 5while "hello from tmux" not in right.capture_pane(): if time.monotonic() >= deadline: raise TimeoutError("The pane did not print hello from tmux") time.sleep(0.02)
# Move the focus an attached client sees: the pane, then the window.right.select()logs.select()
# Walk the objects: down from the server, then up from one pane.sessions = server.sessionsfor each in sessions: print("session", each.session_name) windows = each.windows for window in windows: panes = window.panes ids = " ".join(pane.pane_id for pane in panes) print(f" window {window.window_index}:{window.window_name}: {ids}")window = right.windowowner = window.sessionprint(right.pane_id, "is in window", window.window_name, "of session", owner.session_name)from __future__ import annotations
from pathlib import Pathimport tempfileimport time
import libtmuxfrom libtmux.constants import PaneDirection
directory = Path(tempfile.mkdtemp(prefix="libtmux-py-home-"))socket = directory / "tmux.sock"server = libtmux.Server(socket_path=socket, config_file="/dev/null")
try: session = server.new_session(session_name="demo")
# Lay out the session: name its window, split it, add a second window. editor = session.active_window editor.rename_window("editor") left = editor.active_pane assert left is not None right = left.split(direction=PaneDirection.Right, shell="sh") logs = session.new_window(window_name="logs")
# Type a command into the new pane and wait for what it prints. right.send_keys("printf 'hello from %s\\n' tmux", enter=True) deadline = time.monotonic() + 5 while "hello from tmux" not in right.capture_pane(): if time.monotonic() >= deadline: raise TimeoutError("The pane did not print hello from tmux") time.sleep(0.02)
# Move the focus an attached client sees: the pane, then the window. right.select() logs.select()
# Walk the objects: down from the server, then up from one pane. sessions = server.sessions for each in sessions: print("session", each.session_name) windows = each.windows for window in windows: panes = window.panes ids = " ".join(pane.pane_id for pane in panes) print(f" window {window.window_index}:{window.window_name}: {ids}") window = right.window owner = window.session print(right.pane_id, "is in window", window.window_name, "of session", owner.session_name)except Exception as error: raise RuntimeError("tmux quickstart failed") from errorfrom __future__ import annotations
from pathlib import Pathimport shutilimport tempfileimport time
import libtmuxfrom libtmux.constants import PaneDirection
directory = Path(tempfile.mkdtemp(prefix="libtmux-py-home-"))socket = directory / "tmux.sock"server = libtmux.Server(socket_path=socket, config_file="/dev/null")
try: session = server.new_session(session_name="demo")
# Lay out the session: name its window, split it, add a second window. editor = session.active_window editor.rename_window("editor") left = editor.active_pane assert left is not None right = left.split(direction=PaneDirection.Right, shell="sh") logs = session.new_window(window_name="logs")
# Type a command into the new pane and wait for what it prints. right.send_keys("printf 'hello from %s\\n' tmux", enter=True) deadline = time.monotonic() + 5 while "hello from tmux" not in right.capture_pane(): if time.monotonic() >= deadline: raise TimeoutError("The pane did not print hello from tmux") time.sleep(0.02)
# Move the focus an attached client sees: the pane, then the window. right.select() logs.select()
# Walk the objects: down from the server, then up from one pane. sessions = server.sessions for each in sessions: print("session", each.session_name) windows = each.windows for window in windows: panes = window.panes ids = " ".join(pane.pane_id for pane in panes) print(f" window {window.window_index}:{window.window_name}: {ids}") window = right.window owner = window.session print(right.pane_id, "is in window", window.window_name, "of session", owner.session_name)finally: if socket.exists(): server.kill() shutil.rmtree(directory)from __future__ import annotations
from pathlib import Pathimport shutilimport tempfileimport time
import libtmuxfrom libtmux.constants import PaneDirection
directory = Path(tempfile.mkdtemp(prefix="libtmux-py-home-"))socket = directory / "tmux.sock"server = libtmux.Server(socket_path=socket, config_file="/dev/null")
try: session = server.new_session(session_name="demo")
# Lay out the session: name its window, split it, add a second window. editor = session.active_window editor.rename_window("editor") left = editor.active_pane assert left is not None right = left.split(direction=PaneDirection.Right, shell="sh") logs = session.new_window(window_name="logs")
# Type a command into the new pane and wait for what it prints. right.send_keys("printf 'hello from %s\\n' tmux", enter=True) deadline = time.monotonic() + 5 while "hello from tmux" not in right.capture_pane(): if time.monotonic() >= deadline: raise TimeoutError("The pane did not print hello from tmux") time.sleep(0.02)
# Move the focus an attached client sees: the pane, then the window. right.select() logs.select()
# Walk the objects: down from the server, then up from one pane. sessions = server.sessions for each in sessions: print("session", each.session_name) windows = each.windows for window in windows: panes = window.panes ids = " ".join(pane.pane_id for pane in panes) print(f" window {window.window_index}:{window.window_name}: {ids}") window = right.window owner = window.session print(right.pane_id, "is in window", window.window_name, "of session", owner.session_name)except Exception as error: raise RuntimeError("tmux quickstart failed") from errorfinally: if socket.exists(): server.kill() shutil.rmtree(directory)tmux before the first call: no server is running.
tmux after Server: no server is running; the call sent no command.
tmux after Server.new_session: added session demo.
tmux after Session.active_window: unchanged.
tmux after Window.rename_window: renamed window 0:sh to 0:editor.
tmux after Window.active_pane: unchanged.
tmux after Pane.split: added pane %1 to window 0:editor.
tmux after Session.new_window: added window 1:logs.
tmux after Pane.send_keys: sent keys to pane %1.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Pane.capture_pane: read pane %1.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Pane.select: selected pane %1 in window 0:editor.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Window.select: selected window 1:logs.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Server.sessions: unchanged.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Session.windows: unchanged.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Window.panes: unchanged.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Window.panes: unchanged.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Pane.window: unchanged.
$ printf 'hello from %s\n' tmux hello from tmux $
tmux after Window.session: unchanged.
tmux after Server.kill: the server has exited.
Before the first call
No tmux server is running yet.
{ "socketPath": "/tmp/tmp/libtmux-py-home-azy0qyi_/tmux.sock", "configFile": "/dev/null"}The call sent no tmux command.
Server.new_session returned Session
{ "id": "$0", "name": "demo"}has-session -t =demo error connecting to /tmp/tmp/libtmux-py-home-azy0qyi_/tmux.sock (No such file or directory) new-session -P -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_standar… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞0␞0␞960␞2000␞0␞0␞0␞0␞0␞␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞1␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞79␞␞␞/tmp/marked␞0␞8,16,24,32,40,48,56,64,72␞host␞0␞/dev/pts/14␞80␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞1␞/tmp/libtmux-d… Before these, the library asked tmux about itself 1 time (its version, its daemon, how a control client reads escapes).
Session.active_window returned Window
{ "id": "@0", "index": "0", "name": "sh"}list-windows -t $0 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_sta… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞0␞1␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞1␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞79␞␞␞/tmp/marked␞0␞8,16,24,32,40,48,56,64,72␞host␞0␞/dev/pts/14␞80␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞1␞/tmp/libtmux… Window.rename_window returned Window
{ "id": "@0", "index": "0", "name": "editor"}rename-window -t @0 editor no output list-windows -t @0 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_sta… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞0␞1␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞1␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞79␞␞␞/tmp/marked␞0␞8,16,24,32,40,48,56,64,72␞host␞0␞/dev/pts/14␞80␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞1␞/tmp/libtmux… Window.active_pane returned Pane
{ "id": "%0"}list-panes -t @0 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_stand… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞0␞1␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞1␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞1␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞79␞␞␞/tmp/marked␞0␞8,16,24,32,40,48,56,64,72␞host␞0␞/dev/pts/14␞80␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞1␞/tmp/libtmux… Pane.split returned Pane
{ "id": "%1"}split-window -t %0 -h -P -F#{pane_id}␞ -d sh %1␞ list-panes -t %1 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_stand… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞0␞2␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞0␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞1␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞39␞␞␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/14␞40␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞1␞/tmp/tm… list-windows -t @0 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_sta… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞0␞1␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞0␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞39␞␞␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/14␞40␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞1␞/tmp/tm… list-sessions -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_standard… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞0␞0␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞0␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞39␞␞␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/14␞40␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞1␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞1␞/tmp/tm… list-windows -t @0 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_sta… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞0␞1␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞0␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞39␞␞␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/14␞40␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞1␞/tmp/tm… list-sessions -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_standard… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞0␞0␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞0␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞39␞␞␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/14␞40␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞1␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞1␞/tmp/tm… list-windows -t @0 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_sta… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞0␞1␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞0␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞39␞␞␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/14␞40␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞1␞/tmp/tm… list-windows -t @0 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_sta… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞0␞1␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞0␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞39␞␞␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/14␞40␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞1␞/tmp/tm… Session.new_window returned Window
{ "id": "@1", "index": "1", "name": "logs"}new-window -t $0: -d -P -F#{window_id} -n logs -t$0: @1 list-windows -t @1 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_sta… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞1␞2␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞0␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%0␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞39␞␞␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/14␞40␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞2␞/tmp/tm… Pane.send_keys returned None
nullsend-keys -t %1 'printf '\''hello from %s\n'\'' tmux' no output send-keys -t %1 Enter no output Pane.capture_pane returned list[str]
[ "$ printf 'hello from %s\\n' tmux", "hello from tmux", "$"]capture-pane -t %1 -p $ printf 'hello from %s\n' tmux
hello from tmux
$ Pane.select returned Pane
{ "id": "%1"}select-pane -t %1 no output list-panes -t %1 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_stand… 0␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞1␞2␞0␞0␞0␞0␞0␞$1␞0␞0␞1␞1␞0␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞-␞0␞1␞24␞%0␞0␞0␞0␞1␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞39␞␞␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/14␞40␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞0␞2␞/tmp/tm… Window.select returned Window
{ "id": "@1", "index": "1", "name": "logs"}select-window -t @1 no output list-windows -t @1 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_sta… 1␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞2␞1295␞2000␞0␞0␞0␞0␞1␞2␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞0␞1␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%1␞0␞1␞0␞0␞41␞0␞0␞␞␞0␞hidden␞2890032␞0␞␞79␞␞sh␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/16␞39␞41␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞1,0␞2␞/tmp/libtmux-docs-7y8… Server.sessions returned QueryList[Session]
[ "$0"]list-sessions -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_standard… 1␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞1␞0␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞1␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%2␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2890194␞0␞␞79␞␞␞/tmp/marked␞0␞8,16,24,32,40,48,56,64,72␞host␞0␞/dev/pts/17␞80␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞1␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞1,0␞2␞/tmp/libtm… Session.windows returned QueryList[Window]
[ "@0", "@1"]list-windows -t $0 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_sta… 1␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞2␞1295␞2000␞0␞0␞0␞0␞1␞2␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞0␞1␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%1␞0␞1␞0␞0␞41␞0␞0␞␞␞0␞hidden␞2890032␞0␞␞79␞␞sh␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/16␞39␞41␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞1,0␞2␞/tmp/libtmux-docs-7y8… Window.panes returned QueryList[Pane]
[ "%0", "%1"]list-panes -t @0 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_stand… 1␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞1␞2␞0␞0␞0␞0␞0␞$1␞0␞0␞1␞1␞0␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞-␞0␞1␞24␞%0␞0␞0␞0␞1␞0␞0␞0␞␞␞0␞hidden␞2889449␞0␞␞39␞␞␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/14␞40␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞1,0␞2␞/tmp/… Window.panes returned QueryList[Pane]
[ "%2"]list-panes -t @1 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_stand… 1␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞1␞1␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞1␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞1␞24␞%2␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2890194␞0␞␞79␞␞␞/tmp/marked␞0␞8,16,24,32,40,48,56,64,72␞host␞0␞/dev/pts/17␞80␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞1,0␞2␞/tmp/libtm… Pane.window returned Window
{ "id": "@0", "index": "0", "name": "editor"}list-windows -t @0 -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_sta… 1␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞2␞1295␞2000␞0␞0␞0␞0␞1␞2␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞0␞1␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%1␞0␞1␞0␞0␞41␞0␞0␞␞␞0␞hidden␞2890032␞0␞␞79␞␞sh␞/tmp/marked␞0␞8,16,24,32␞host␞0␞/dev/pts/16␞39␞41␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞0␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞1,0␞2␞/tmp/libtmux-docs-7y8… Window.session returned Session
{ "id": "$0", "name": "demo"}list-sessions -F#{active_window_index}␞#{alternate_saved_x}␞#{alternate_saved_y}␞#{bracket_paste_flag}␞#{config_files}␞#{cursor_character}␞#{cursor_flag}␞#{cursor_x}␞#{cursor_y}␞#{history_bytes}␞#{history_limit}␞#{history_size}␞#{insert_flag}␞#{keypad_cursor_flag}␞#{keypad_flag}␞#{last_window_index}␞#{line}␞#{mouse_all_flag}␞#{mouse_any_flag}␞#{mouse_button_flag}␞#{mouse_sgr_flag}␞#{mouse_standard… 1␞4294967295␞4294967295␞0␞/dev/null␞ ␞1␞2␞0␞1060␞2000␞0␞0␞0␞0␞1␞0␞0␞0␞0␞0␞0␞$1␞0␞1␞1␞1␞1␞1␞default␞23␞sh␞/tmp/marked␞0␞␞␞␞default␞*␞0␞0␞24␞%2␞0␞0␞0␞0␞0␞0␞0␞␞␞0␞hidden␞2890194␞0␞␞79␞␞␞/tmp/marked␞0␞8,16,24,32,40,48,56,64,72␞host␞0␞/dev/pts/17␞80␞0␞0␞1␞0␞2889448␞23␞0␞1793886161␞␞0␞␞1793886161␞1␞␞␞␞␞␞␞0␞$0␞␞0␞0␞demo␞/tmp/marked␞1,0␞2␞/tmp/libtm… Server.kill returned None
nullkill-server no output POSIX shell, tmux 3.2a or newer, Python 3.14.6 and uv (tested 0.12.0).
Save the program above as quickstart.py in a new directory, along with the files below.
Cleanup is omitted; the private tmux server and its temporary files may remain. Select Cleanup to remove them when the program finishes. The program stops its private tmux server and removes any temporary files it created when it finishes. Error handling adds diagnostics; every version checks required results and deadlines.
uv venv .venvuv pip install --python .venv/bin/python libtmux==0.62.0unset TMUX TMUX_PANEexport ENV=/dev/null BASH_ENV=/dev/null SHELL=/bin/sh.venv/bin/python quickstart.pysession demo window 0:editor: %0 %1 window 1:logs: %2%1 is in window editor of session demolibtmux$ pip install libtmux$ pip install libtmux$ pip install libtmux$ uv add libtmux$ uv add \
--exclude-newer P7D \
--exclude-newer-package libtmux=2099-01-01 \
libtmux$ uv add --no-config libtmux$ pipx install libtmux$ pipx install libtmux$ pipx install libtmux$ uv add "libtmux @ git+https://github.com/tmux-python/libtmux@v0.62.0"Pins the tagged source; the registry release is the default.
Give an assistant tmux tools pre-alpha Early development; expect breaking changes. Read more MCP home →
tmux before the first call.
tmux after create_session.
tmux after split_window.
tmux after list_windows: unchanged, the call only reads.
$ pytest -q $ ( pytest -q .. [100%] 2 passed in 0.01s $
tmux after run_command.
$ pytest -q $ ( pytest -q .. [100%] 2 passed in 0.01s $
$ cat checks.log $ ( cat checks.log 2026-01-01 checks started 2026-01-01 checks finished $
tmux after run_command.
tmux after kill_session.
Create a tmux session called checks, split its window into two panes, run pytest -q in one and show checks.log in the other, show me the results, then remove the session.
AgentCreate the session.
{ "session_id": "$0", "session_name": "checks", "window_count": 1, "session_attached": "0", "session_created": "1795059312", "active_pane_id": "%0"}AgentSplit the pane the create result returned (%0) in two.
{ "pane_id": "%1", "pane_index": "1", "pane_width": "39", "pane_height": "24", "pane_left": 41, "pane_top": 0, "pane_right": 79, "pane_bottom": 23, "pane_at_left": false, "pane_at_right": true, "pane_at_top": true, "pane_at_bottom": true, "…": "9 more"}AgentRead the window's layout.
{ "result": [ { "window_id": "@0", "window_name": "sh", "window_index": "0", "session_id": "$0", "session_name": "checks", "pane_count": 2, "window_layout": "8205,80x24,0,0{40x24,0,0,0,39x24,41,0,1}", "window_active": "1", "window_width": "80", "window_height": "24", "active_pane_id": "%0" } ]}AgentRun the tests in the pane the create result returned (%0).
{ "pane_id": "%0", "exit_status": 0, "timed_out": false, "elapsed_seconds": 0.8076037850041757, "output": [ "$ (", "pytest -q", ".. [100%]", "2 passed in 0.01s", "… 1 more" ], "output_truncated": false, "output_truncated_lines": 0, "effective_timeout": 30}AgentShow the log in the new pane the split returned (%1).
{ "pane_id": "%1", "exit_status": 0, "timed_out": false, "elapsed_seconds": 0.029483657999662682, "output": [ "$ (", "cat checks.log", "2026-01-01 checks started", "2026-01-01 checks finished", "… 1 more" ], "output_truncated": false, "output_truncated_lines": 0, "effective_timeout": 30}AgentRemove the session once the result is read.
{ "result": "Session killed: checks"}pytest printed 2 passed and checks.log ends with checks finished. I removed the checks session.
libtmux-mcpChoose your client and configuration scope, then run the command or paste the configuration.
$ claude mcp add tmux -- uvx libtmux-mcp$ claude mcp add tmux \
-- uvx \
--exclude-newer P7D \
--exclude-newer-package libtmux-mcp=2099-01-01 \
libtmux-mcp$ claude mcp add tmux -- uvx --no-config libtmux-mcp$ claude mcp add tmux --scope user -- uvx libtmux-mcp$ claude mcp add tmux \
--scope user \
-- uvx \
--exclude-newer P7D \
--exclude-newer-package libtmux-mcp=2099-01-01 \
libtmux-mcp$ claude mcp add tmux --scope user -- uvx --no-config libtmux-mcp$ claude mcp add tmux --scope project -- uvx libtmux-mcp$ claude mcp add tmux \
--scope project \
-- uvx \
--exclude-newer P7D \
--exclude-newer-package libtmux-mcp=2099-01-01 \
libtmux-mcp$ claude mcp add tmux --scope project -- uvx --no-config libtmux-mcp$ claude mcp add tmux -- pipx run libtmux-mcp$ claude mcp add tmux -- pipx run libtmux-mcp$ claude mcp add tmux -- pipx run libtmux-mcp$ claude mcp add tmux --scope user -- pipx run libtmux-mcp$ claude mcp add tmux --scope user -- pipx run libtmux-mcp$ claude mcp add tmux --scope user -- pipx run libtmux-mcp$ claude mcp add tmux --scope project -- pipx run libtmux-mcp$ claude mcp add tmux --scope project -- pipx run libtmux-mcp$ claude mcp add tmux --scope project -- pipx run libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ claude mcp add tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ claude mcp add tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ claude mcp add tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ claude mcp add tmux --scope user -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ claude mcp add tmux --scope user -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ claude mcp add tmux --scope user -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ claude mcp add tmux --scope project -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ claude mcp add tmux --scope project -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ claude mcp add tmux --scope project -- libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["--exclude-newer", "P7D", "--exclude-newer-package", "libtmux-mcp=2099-01-01", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["libtmux-mcp"],
"env": { "UV_NO_CONFIG": "1" }
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ codex mcp add tmux -- uvx libtmux-mcp$ codex mcp add tmux \
-- uvx \
--exclude-newer P7D \
--exclude-newer-package libtmux-mcp=2099-01-01 \
libtmux-mcp$ codex mcp add tmux -- uvx --no-config libtmux-mcp[mcp_servers.tmux]
command = "uvx"
args = ["libtmux-mcp"][mcp_servers.tmux]
command = "uvx"
args = ["--exclude-newer", "P7D", "--exclude-newer-package", "libtmux-mcp=2099-01-01", "libtmux-mcp"][mcp_servers.tmux]
command = "uvx"
args = ["libtmux-mcp"]
env = { UV_NO_CONFIG = "1" }$ codex mcp add tmux -- pipx run libtmux-mcp$ codex mcp add tmux -- pipx run libtmux-mcp$ codex mcp add tmux -- pipx run libtmux-mcp[mcp_servers.tmux]
command = "pipx"
args = ["run", "libtmux-mcp"][mcp_servers.tmux]
command = "pipx"
args = ["run", "libtmux-mcp"][mcp_servers.tmux]
command = "pipx"
args = ["run", "libtmux-mcp"]$ pip install --user --upgrade libtmux libtmux-mcp$ codex mcp add tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ codex mcp add tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ codex mcp add tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp[mcp_servers.tmux]
command = "libtmux-mcp"$ pip install --user --upgrade libtmux libtmux-mcp[mcp_servers.tmux]
command = "libtmux-mcp"$ pip install --user --upgrade libtmux libtmux-mcp[mcp_servers.tmux]
command = "libtmux-mcp"$ gemini mcp add --scope user tmux uvx -- libtmux-mcp$ gemini mcp add \
--scope user \
tmux uvx \
-- --exclude-newer P7D \
--exclude-newer-package libtmux-mcp=2099-01-01 \
libtmux-mcp$ gemini mcp add --scope user tmux uvx -- --no-config libtmux-mcp$ gemini mcp add --scope project tmux uvx -- libtmux-mcp$ gemini mcp add \
--scope project \
tmux uvx \
-- --exclude-newer P7D \
--exclude-newer-package libtmux-mcp=2099-01-01 \
libtmux-mcp$ gemini mcp add --scope project tmux uvx -- --no-config libtmux-mcp$ gemini mcp add --scope user tmux pipx -- run libtmux-mcp$ gemini mcp add --scope user tmux pipx -- run libtmux-mcp$ gemini mcp add --scope user tmux pipx -- run libtmux-mcp$ gemini mcp add --scope project tmux pipx -- run libtmux-mcp$ gemini mcp add --scope project tmux pipx -- run libtmux-mcp$ gemini mcp add --scope project tmux pipx -- run libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ gemini mcp add --scope user tmux libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ gemini mcp add --scope user tmux libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ gemini mcp add --scope user tmux libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ gemini mcp add --scope project tmux libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ gemini mcp add --scope project tmux libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ gemini mcp add --scope project tmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["--exclude-newer", "P7D", "--exclude-newer-package", "libtmux-mcp=2099-01-01", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["libtmux-mcp"],
"env": { "UV_NO_CONFIG": "1" }
}
}
}{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["--exclude-newer", "P7D", "--exclude-newer-package", "libtmux-mcp=2099-01-01", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["libtmux-mcp"],
"env": { "UV_NO_CONFIG": "1" }
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ grok mcp add --scope user tmux -- uvx libtmux-mcp$ grok mcp add \
--scope user \
tmux \
-- uvx \
--exclude-newer P7D \
--exclude-newer-package libtmux-mcp=2099-01-01 \
libtmux-mcp$ grok mcp add --scope user tmux -- uvx --no-config libtmux-mcp$ grok mcp add --scope project tmux -- uvx libtmux-mcp$ grok mcp add \
--scope project \
tmux \
-- uvx \
--exclude-newer P7D \
--exclude-newer-package libtmux-mcp=2099-01-01 \
libtmux-mcp$ grok mcp add --scope project tmux -- uvx --no-config libtmux-mcp$ grok mcp add --scope user tmux -- pipx run libtmux-mcp$ grok mcp add --scope user tmux -- pipx run libtmux-mcp$ grok mcp add --scope user tmux -- pipx run libtmux-mcp$ grok mcp add --scope project tmux -- pipx run libtmux-mcp$ grok mcp add --scope project tmux -- pipx run libtmux-mcp$ grok mcp add --scope project tmux -- pipx run libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ grok mcp add --scope user tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ grok mcp add --scope user tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ grok mcp add --scope user tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ grok mcp add --scope project tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ grok mcp add --scope project tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ grok mcp add --scope project tmux -- libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["--exclude-newer", "P7D", "--exclude-newer-package", "libtmux-mcp=2099-01-01", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "uvx",
"args": ["libtmux-mcp"],
"env": { "UV_NO_CONFIG": "1" }
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}{
"mcpServers": {
"tmux": {
"command": "pipx",
"args": ["run", "libtmux-mcp"]
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ pip install --user --upgrade libtmux libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "libtmux-mcp"
}
}
}$ opencode mcp add tmux -- uvx libtmux-mcp$ opencode mcp add tmux \
-- uvx \
--exclude-newer P7D \
--exclude-newer-package libtmux-mcp=2099-01-01 \
libtmux-mcp$ opencode mcp add tmux -- uvx --no-config libtmux-mcp$ opencode mcp add tmux -- pipx run libtmux-mcp$ opencode mcp add tmux -- pipx run libtmux-mcp$ opencode mcp add tmux -- pipx run libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ opencode mcp add tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ opencode mcp add tmux -- libtmux-mcp$ pip install --user --upgrade libtmux libtmux-mcp$ opencode mcp add tmux -- libtmux-mcpWrites ~/.claude.json (this project).
With uvx installed.
Writes ~/.claude.json (this project).
With uvx installed.
Writes ~/.claude.json (this project).
With uvx installed.
Writes ~/.claude.json (all projects).
With uvx installed.
Writes ~/.claude.json (all projects).
With uvx installed.
Writes ~/.claude.json (all projects).
With uvx installed.
Writes .mcp.json (in repo, version-controlled).
With uvx installed.
Writes .mcp.json (in repo, version-controlled).
With uvx installed.
Writes .mcp.json (in repo, version-controlled).
With uvx installed.
Writes ~/.claude.json (this project).
With pipx installed.
Writes ~/.claude.json (this project).
With pipx installed.
Writes ~/.claude.json (this project).
With pipx installed.
Writes ~/.claude.json (all projects).
With pipx installed.
Writes ~/.claude.json (all projects).
With pipx installed.
Writes ~/.claude.json (all projects).
With pipx installed.
Writes .mcp.json (in repo, version-controlled).
With pipx installed.
Writes .mcp.json (in repo, version-controlled).
With pipx installed.
Writes .mcp.json (in repo, version-controlled).
With pipx installed.
Writes ~/.claude.json (this project).
Writes ~/.claude.json (this project).
Writes ~/.claude.json (this project).
Writes ~/.claude.json (all projects).
Writes ~/.claude.json (all projects).
Writes ~/.claude.json (all projects).
Writes .mcp.json (in repo, version-controlled).
Writes .mcp.json (in repo, version-controlled).
Writes .mcp.json (in repo, version-controlled).
With uvx installed.
With uvx installed.
With uvx installed.
With pipx installed.
With pipx installed.
With pipx installed.
Writes ~/.codex/config.toml.
With uvx installed.
Writes ~/.codex/config.toml.
With uvx installed.
Writes ~/.codex/config.toml.
With uvx installed.
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
With uvx installed.
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
With uvx installed.
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
With uvx installed.
Writes ~/.codex/config.toml.
With pipx installed.
Writes ~/.codex/config.toml.
With pipx installed.
Writes ~/.codex/config.toml.
With pipx installed.
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
With pipx installed.
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
With pipx installed.
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
With pipx installed.
Writes ~/.codex/config.toml.
Writes ~/.codex/config.toml.
Writes ~/.codex/config.toml.
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
Writes ~/.gemini/settings.json.
With uvx installed.
Writes ~/.gemini/settings.json.
With uvx installed.
Writes ~/.gemini/settings.json.
With uvx installed.
Writes .gemini/settings.json (in repo).
With uvx installed.
Writes .gemini/settings.json (in repo).
With uvx installed.
Writes .gemini/settings.json (in repo).
With uvx installed.
Writes ~/.gemini/settings.json.
With pipx installed.
Writes ~/.gemini/settings.json.
With pipx installed.
Writes ~/.gemini/settings.json.
With pipx installed.
Writes .gemini/settings.json (in repo).
With pipx installed.
Writes .gemini/settings.json (in repo).
With pipx installed.
Writes .gemini/settings.json (in repo).
With pipx installed.
Writes ~/.gemini/settings.json.
Writes ~/.gemini/settings.json.
Writes ~/.gemini/settings.json.
Writes .gemini/settings.json (in repo).
Writes .gemini/settings.json (in repo).
Writes .gemini/settings.json (in repo).
With uvx installed.
With uvx installed.
With uvx installed.
With uvx installed.
With uvx installed.
With uvx installed.
With pipx installed.
With pipx installed.
With pipx installed.
With pipx installed.
With pipx installed.
With pipx installed.
Writes ~/.grok/config.toml.
With uvx installed.
Writes ~/.grok/config.toml.
With uvx installed.
Writes ~/.grok/config.toml.
With uvx installed.
Writes ./.grok/config.toml (in repo).
With uvx installed.
Writes ./.grok/config.toml (in repo).
With uvx installed.
Writes ./.grok/config.toml (in repo).
With uvx installed.
Writes ~/.grok/config.toml.
With pipx installed.
Writes ~/.grok/config.toml.
With pipx installed.
Writes ~/.grok/config.toml.
With pipx installed.
Writes ./.grok/config.toml (in repo).
With pipx installed.
Writes ./.grok/config.toml (in repo).
With pipx installed.
Writes ./.grok/config.toml (in repo).
With pipx installed.
Writes ~/.grok/config.toml.
Writes ~/.grok/config.toml.
Writes ~/.grok/config.toml.
Writes ./.grok/config.toml (in repo).
Writes ./.grok/config.toml (in repo).
Writes ./.grok/config.toml (in repo).
With uvx installed.
With uvx installed.
With uvx installed.
With pipx installed.
With pipx installed.
With pipx installed.
Writes ~/.config/opencode/opencode.jsonc.
With uvx installed.
Writes ~/.config/opencode/opencode.jsonc.
With uvx installed.
Writes ~/.config/opencode/opencode.jsonc.
With uvx installed.
Writes ~/.config/opencode/opencode.jsonc.
With pipx installed.
Writes ~/.config/opencode/opencode.jsonc.
With pipx installed.
Writes ~/.config/opencode/opencode.jsonc.
With pipx installed.
Writes ~/.config/opencode/opencode.jsonc.
Writes ~/.config/opencode/opencode.jsonc.
Writes ~/.config/opencode/opencode.jsonc.
Load a workspace file 1.x Released; the API may change. Read more Workspace Manager home →
The main-horizontal layout gives the first pane the top of the window and splits the rest below it.
session_name: sample workspacestart_directory: '~'windows:- window_name: test layout: main-horizontal panes: - shell_command: - cmd: vim - shell_command: - cmd: echo "hey" - shell_command: - cmd: echo "moo"{ "session_name": "sample workspace", "start_directory": "~", "windows": [ { "window_name": "test", "layout": "main-horizontal", "panes": [ { "shell_command": [ { "cmd": "vim" } ] }, { "shell_command": [ { "cmd": "echo \"hey\"" } ] }, { "shell_command": [ { "cmd": "echo \"moo\"" } ] } ] } ]}
Workspace file: tests/fixtures/workspace/builder/three_pane.yaml.
Tested by test_layout_main_horizontal
(tests/workspace/test_builder.py; built by the library in a test; the command is not run).
A pane can be one command written as a string, and a command list can be one string.
session_name: sample workspacestart_directory: '~'windows:- window_name: focused window layout: main-horizontal focus: true panes: - shell_command: - cd ~ - shell_command: - cd /usr focus: true - shell_command: - cd ~ - echo "moo" - top- window_name: window 2 panes: - shell_command: - top focus: true - shell_command: - echo "hey" - shell_command: - echo "moo"- window_name: window 3 panes: - shell_command: cd / focus: true - pane - pane{ "session_name": "sample workspace", "start_directory": "~", "windows": [ { "window_name": "focused window", "layout": "main-horizontal", "focus": true, "panes": [ { "shell_command": [ "cd ~" ] }, { "shell_command": [ "cd /usr" ], "focus": true }, { "shell_command": [ "cd ~", "echo \"moo\"", "top" ] } ] }, { "window_name": "window 2", "panes": [ { "shell_command": [ "top" ], "focus": true }, { "shell_command": [ "echo \"hey\"" ] }, { "shell_command": [ "echo \"moo\"" ] } ] }, { "window_name": "window 3", "panes": [ { "shell_command": "cd /", "focus": true }, "pane", "pane" ] } ]}
Workspace file: tests/fixtures/workspace/expand2-unexpanded.yaml.
Tested by test_workspace_expand2
(tests/workspace/test_config.py; loaded by the library in a test; the command is not run).
A window of two panes.
session_name: sample workspacestart_directory: '~'windows:- layout: main-vertical panes: - shell_command: - cmd: vim - shell_command: - cmd: echo "hey" window_name: editor- panes: - shell_command: - cmd: tail | echo 'hi' window_name: logging- window_name: test panes: - shell_command: - cmd: htop{ "session_name": "sample workspace", "start_directory": "~", "windows": [ { "layout": "main-vertical", "panes": [ { "shell_command": [ { "cmd": "vim" } ] }, { "shell_command": [ { "cmd": "echo \"hey\"" } ] } ], "window_name": "editor" }, { "panes": [ { "shell_command": [ { "cmd": "tail | echo 'hi'" } ] } ], "window_name": "logging" }, { "window_name": "test", "panes": [ { "shell_command": [ { "cmd": "htop" } ] } ] } ]}
Workspace file: tests/fixtures/workspace/builder/two_pane.yaml.
Tested by test_split_windows
(tests/workspace/test_builder.py; built by the library in a test; the command is not run).
shell_command_before runs ahead of a pane's own commands, at the session, window or pane level.
shell_command_before: - 'echo "hi"'session_name: 'test'windows:- window_name: editor panes: - shell_command: - vim - :Ex - pane - cd /usr- window_name: logging panes: - shell_command: - - shell_command: - top - emacs{ "shell_command_before": [ "echo \"hi\"" ], "session_name": "test", "windows": [ { "window_name": "editor", "panes": [ { "shell_command": [ "vim", ":Ex" ] }, "pane", "cd /usr" ] }, { "window_name": "logging", "panes": [ { "shell_command": [ null ] }, { "shell_command": [ "top", "emacs" ] } ] } ]}
Workspace file: tests/fixtures/workspace/shell_command_before_session.yaml.
Tested by test_in_session_scope
(tests/workspace/test_config.py; loaded by the library in a test; the command is not run).
environment sets variables for a session, a window or a pane.
session_name: test env varsstart_directory: "~"environment: FOO: SESSION PATH: /tmpwindows:- window_name: no_overrides panes: - pane- window_name: window_overrides environment: FOO: WINDOW panes: - pane- window_name: pane_overrides panes: - environment: FOO: PANE- window_name: both_overrides environment: FOO: WINDOW panes: - pane - environment: FOO: PANE# This test case it just needed for warnings issued in old versions of tmux.- window_name: both_overrides_on_first_pane environment: FOO: WINDOW panes: - environment: FOO: PANE{ "session_name": "test env vars", "start_directory": "~", "environment": { "FOO": "SESSION", "PATH": "/tmp" }, "windows": [ { "window_name": "no_overrides", "panes": [ "pane" ] }, { "window_name": "window_overrides", "environment": { "FOO": "WINDOW" }, "panes": [ "pane" ] }, { "window_name": "pane_overrides", "panes": [ { "environment": { "FOO": "PANE" } } ] }, { "window_name": "both_overrides", "environment": { "FOO": "WINDOW" }, "panes": [ "pane", { "environment": { "FOO": "PANE" } } ] }, { "window_name": "both_overrides_on_first_pane", "environment": { "FOO": "WINDOW" }, "panes": [ { "environment": { "FOO": "PANE" } } ] } ]}
Workspace file: tests/fixtures/workspace/builder/environment_vars.yaml.
Tested by test_environment_variables
(tests/workspace/test_builder.py; built by the library in a test; the command is not run).
start_directory chooses where a session, a window or a pane starts.
session_name: sample workspacewindows: - panes: - start_directory: /usr - start_directory: /etc{ "session_name": "sample workspace", "windows": [ { "panes": [ { "start_directory": "/usr" }, { "start_directory": "/etc" } ] } ]}
Workspace file: tests/fixtures/workspace/builder/first_pane_start_directory.yaml.
Tested by test_first_pane_start_directory
(tests/workspace/test_builder.py; built by the library in a test; the command is not run).
An empty entry, null, pane or blank opens a pane with no command.
session_name: Blank pane testwindows: # Emptiness will simply open a blank pane, if no shell_command_before. # All these are equivalent - window_name: Blank pane test panes: - - pane - blank - window_name: More blank panes panes: - null - shell_command: - shell_command: - # an empty string will be treated as a carriage return - window_name: Empty string (return) panes: - "" - shell_command: "" - shell_command: - "" # a pane can have other options but still be blank - window_name: Blank with options panes: - focus: true - start_directory: /tmp{ "session_name": "Blank pane test", "windows": [ { "window_name": "Blank pane test", "panes": [ null, "pane", "blank" ] }, { "window_name": "More blank panes", "panes": [ null, { "shell_command": null }, { "shell_command": [ null ] } ] }, { "window_name": "Empty string (return)", "panes": [ "", { "shell_command": "" }, { "shell_command": [ "" ] } ] }, { "window_name": "Blank with options", "panes": [ { "focus": true }, { "start_directory": "/tmp" } ] } ]}
Workspace file: examples/blank-panes.yaml.
Tested by test_blank_pane_spawn
(tests/workspace/test_builder.py; built by the library in a test; the command is not run).
tmuxpThe workspace package is separate from the core library.
$ uv tool install tmuxp$ tmuxp load ./workspace.yaml$ uvx tmuxp --help$ pipx install tmuxp$ tmuxp load ./workspace.yamlInstalls tmuxp in an isolated Python environment. Run tmuxp load ./workspace.yaml.
Runs without a permanent installation. Replace --help with load ./workspace.yaml to load a workspace.
Installs the tmuxp command in an isolated Python environment.
>>> import yaml
>>> session_config = yaml.load('''... session_name: sample workspace... start_directory: '~'... windows:... - window_name: editor... layout: main-vertical... panes:... - shell_command:... - cmd: vim... - shell_command:... - cmd: echo "hey"...... - window_name: logging... panes:... - shell_command:... - cmd: tail | echo 'hi'...... - window_name: test... panes:... - shell_command:... - cmd: htop... ''', Loader=yaml.Loader)
>>> builder = ClassicWorkspaceBuilder(session_config=session_config, server=server)
**New session:**
>>> builder.build()
>>> new_session = builder.session
>>> new_session.name == 'sample workspace'True
Excerpt of src/tmuxp/workspace/builder/classic.py.
This program is tested on every change.
Subject-by-subject, with Python in every code block.
Task guides for Python.
Complete programs, sourced from the code each port tests.
The domain model every port shares.
Reference preview