PythonHome

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

libtmux for Python

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

Product
from __future__ import annotations
from pathlib import Path
import tempfile
import time
import libtmux
from 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_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)
from __future__ import annotations
from pathlib import Path
import tempfile
import time
import libtmux
from 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 error
from __future__ import annotations
from pathlib import Path
import shutil
import tempfile
import time
import libtmux
from 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 Path
import shutil
import tempfile
import time
import libtmux
from 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 error
finally:
if socket.exists():
server.kill()
shutil.rmtree(directory)
Example details
No tmux server yet

tmux before the first call: no server is running.

No tmux server yet

tmux after Server: no server is running; the call sent no command.

%0 sh
[demo]

tmux after Server.new_session: added session demo.

%0 sh
[demo]

tmux after Session.active_window: unchanged.

%0 sh
[demo]

tmux after Window.rename_window: renamed window 0:sh to 0:editor.

%0 sh
[demo]

tmux after Window.active_pane: unchanged.

%0 sh
%1 sh
[demo]

tmux after Pane.split: added pane %1 to window 0:editor.

%0 sh
%1 sh
[demo]

tmux after Session.new_window: added window 1:logs.

%0 sh
%1 sh
[demo]

tmux after Pane.send_keys: sent keys to pane %1.

%0 sh
%1 sh
$ printf 'hello from %s\n' tmux
hello from tmux
$
[demo]

tmux after Pane.capture_pane: read pane %1.

%0 sh
%1 sh
$ printf 'hello from %s\n' tmux
hello from tmux
$
[demo]

tmux after Pane.select: selected pane %1 in window 0:editor.

%2 sh
[demo]

tmux after Window.select: selected window 1:logs.

%2 sh
[demo]

tmux after Server.sessions: unchanged.

%2 sh
[demo]

tmux after Session.windows: unchanged.

%2 sh
[demo]

tmux after Window.panes: unchanged.

%2 sh
[demo]

tmux after Window.panes: unchanged.

%2 sh
[demo]

tmux after Pane.window: unchanged.

%2 sh
[demo]

tmux after Window.session: unchanged.

No sessions

tmux after Server.kill: the server has exited.

Before the first call

No tmux server is running yet.

Server returned Server

{
"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"
}
2 tmux commands, 1 that changes tmux
  1. has-session -t =demo error connecting to /tmp/tmp/libtmux-py-home-azy0qyi_/tmux.sock (No such file or directory)
  2. 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"
}
1 tmux command
  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… 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"
}
2 tmux commands, 1 that changes tmux
  1. rename-window -t @0 editor no output
  2. 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"
}
1 tmux command
  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… 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"
}
8 tmux commands, 1 that changes tmux
  1. split-window -t %0 -h -P -F#{pane_id}␞ -d sh %1␞
  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… 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…
  3. 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…
  4. 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…
  5. 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…
  6. 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…
  7. 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…
  8. 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"
}
2 tmux commands, 1 that changes tmux
  1. new-window -t $0: -d -P -F#{window_id} -n logs -t$0: @1
  2. 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

null
2 tmux commands, 2 that change tmux
  1. send-keys -t %1 'printf '\''hello from %s\n'\'' tmux' no output
  2. send-keys -t %1 Enter no output

Pane.capture_pane returned list[str]

[
"$ printf 'hello from %s\\n' tmux",
"hello from tmux",
"$"
]
1 tmux command
  1. capture-pane -t %1 -p $ printf 'hello from %s\n' tmux hello from tmux $

Pane.select returned Pane

{
"id": "%1"
}
2 tmux commands, 1 that changes tmux
  1. select-pane -t %1 no output
  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… 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"
}
2 tmux commands, 1 that changes tmux
  1. select-window -t @1 no output
  2. 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"
]
1 tmux command
  1. 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"
]
1 tmux command
  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"
]
1 tmux command
  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"
]
1 tmux command
  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… 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"
}
1 tmux command
  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.session returned Session

{
"id": "$0",
"name": "demo"
}
1 tmux command
  1. 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

null
1 tmux command, 1 that changes tmux
  1. kill-server no output
0/17
Run this example

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.

Setup and run

uv venv .venv
uv pip install --python .venv/bin/python libtmux==0.62.0
unset TMUX TMUX_PANE
export ENV=/dev/null BASH_ENV=/dev/null SHELL=/bin/sh
.venv/bin/python quickstart.py

Expected output

session demo
window 0:editor: %0 %1
window 1:logs: %2
%1 is in window editor of session demo

Install libtmux

Dependency cooldowns

The checkbox turns a cooldown on and off for every picker on the site. It applies to what an install pulls in; the package itself, and the libtmux it pins, stay current.

Cooldown type
What are cooldowns?

Cooldowns delay picking up newly uploaded packages so the community has time to spot supply-chain attacks before you install. Most package managers don't apply one by default; you opt in through a global setting in your tool's configuration.

Learn more at cooldowns.dev · Datadog Security Labs writeup.

$ pip install libtmux
$ pip install libtmux

pip cannot exempt libtmux from its own cooldown, so a cooldown here would also hold back the release this installs. This command runs without one.

$ pip install libtmux

pip cannot exempt libtmux from its own cooldown, so a cooldown here would also hold back the release this installs. This command runs without one.

$ 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 cannot exempt libtmux from its own cooldown, so a cooldown here would also hold back the release this installs. This command runs without one.

$ pipx install libtmux

pipx cannot exempt libtmux from its own cooldown, so a cooldown here would also hold back the release this installs. This command runs without one.

MCP

tmux through MCP

Replay Hover a call to preview the tmux state after it. Click to pin it.

tmux before the first call.

tmux window of 1 pane
%0 sh
[checks] 0:sh*

tmux after create_session.

tmux window of 2 panes
%0 sh
%1 sh
[checks] 0:sh*

tmux after split_window.

tmux window of 2 panes
%0 sh
%1 sh
[checks] 0:sh*

tmux after list_windows: unchanged, the call only reads.

tmux window of 2 panes
%0 sh
$ pytest -q
$  (
pytest -q
..                               [100%]
2 passed in 0.00s
$
%1 sh
[checks] 0:sh*

tmux after run_command.

tmux window of 2 panes
%0 sh
$ pytest -q
$  (
pytest -q
..                               [100%]
2 passed in 0.00s
$
%1 sh
$ cat checks.log
$  (
cat checks.log
2026-01-01 checks started
2026-01-01 checks finished
$
[checks] 0:sh*

tmux after run_command.

No sessions

tmux after kill_session.

you

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.

create_session Execute {"session_name":"checks"}
Result
{
"session_id": "$0",
"session_name": "checks",
"window_count": 1,
"session_attached": "0",
"session_created": "1793756857",
"active_pane_id": "%0"
}

agentSplit the pane the create result returned (%0) in two.

split_window Execute {"pane_id":"%0","direction":"right"}
Result
{
"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.

list_windows Inspect {"session_name":"checks"}
Result
{
"result": [
{
"window_id": "@0",
"window_name": "sh",
"window_index": "0",
"session_id": "$0",
"session_name": "checks",
"pane_count": 2,
"window_layout": "{\"V\":2,\"L\":{\"t\":\"h\",\"w\":80,\"h\":24,\"x\":0,\"y\":0,\"c\":[{\"t\":\"p\",\"w\":40,\"h\":24,\"x\":0,\"y\":0,\"a\":true,\"i\":0,\"I\":\"%0\"},{\"t\":\"p\",\"w\":39,\"h\":24,\"x\":41,\"y\":0,\"i\":1,\"I\":\"%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).

run_command Execute {"pane_id":"%0","command":"pytest -q"}
Result
{
"pane_id": "%0",
"exit_status": 0,
"timed_out": false,
"elapsed_seconds": 0.3231329689733684,
"output": [
"$ (",
"pytest -q",
".. [100%]",
"2 passed in 0.00s",
"… 1 more"
],
"output_truncated": false,
"output_truncated_lines": 0,
"effective_timeout": 30
}

agentShow the log in the new pane the split returned (%1).

run_command Execute {"pane_id":"%1","command":"cat checks.log"}
Result
{
"pane_id": "%1",
"exit_status": 0,
"timed_out": false,
"elapsed_seconds": 0.009672012005466968,
"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.

kill_session Teardown {"session_name":"checks"}
Result
{
"result": "Session killed: checks"
}

agent in %0 it printed 2 passed in 0.00s; in %1 it printed 2026-01-01 checks finished.

0/6

Install libtmux-mcp

Choose your client and configuration scope, then run the command or paste the configuration.

With uvx installed:

$ claude mcp add tmux -- uvx libtmux-mcp

Config file: ~/.claude.json (this project)

With uvx installed:

$ claude mcp add tmux -- uvx --exclude-newer P7D \
    --exclude-newer-package libtmux-mcp=2099-01-01 libtmux-mcp

Config file: ~/.claude.json (this project)

With uvx installed:

$ claude mcp add tmux -- uvx --no-config libtmux-mcp

Config file: ~/.claude.json (this project)

With uvx installed:

$ claude mcp add tmux --scope user -- uvx libtmux-mcp

Config file: ~/.claude.json (all projects)

With uvx installed:

$ claude mcp add tmux --scope user -- uvx --exclude-newer P7D \
    --exclude-newer-package libtmux-mcp=2099-01-01 libtmux-mcp

Config file: ~/.claude.json (all projects)

With uvx installed:

$ claude mcp add tmux --scope user -- uvx --no-config libtmux-mcp

Config file: ~/.claude.json (all projects)

With uvx installed:

$ claude mcp add tmux --scope project -- uvx libtmux-mcp

Config file: .mcp.json (in repo, version-controlled)

With uvx installed:

$ claude mcp add tmux --scope project -- uvx --exclude-newer P7D \
    --exclude-newer-package libtmux-mcp=2099-01-01 libtmux-mcp

Config file: .mcp.json (in repo, version-controlled)

With uvx installed:

$ claude mcp add tmux --scope project -- uvx --no-config libtmux-mcp

Config file: .mcp.json (in repo, version-controlled)

With pipx installed:

$ claude mcp add tmux -- pipx run libtmux-mcp

Config file: ~/.claude.json (this project)

With pipx installed:

$ claude mcp add tmux -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.claude.json (this project)

With pipx installed:

$ claude mcp add tmux -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.claude.json (this project)

With pipx installed:

$ claude mcp add tmux --scope user -- pipx run libtmux-mcp

Config file: ~/.claude.json (all projects)

With pipx installed:

$ claude mcp add tmux --scope user -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.claude.json (all projects)

With pipx installed:

$ claude mcp add tmux --scope user -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.claude.json (all projects)

With pipx installed:

$ claude mcp add tmux --scope project -- pipx run libtmux-mcp

Config file: .mcp.json (in repo, version-controlled)

With pipx installed:

$ claude mcp add tmux --scope project -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .mcp.json (in repo, version-controlled)

With pipx installed:

$ claude mcp add tmux --scope project -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .mcp.json (in repo, version-controlled)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ claude mcp add tmux -- libtmux-mcp

Config file: ~/.claude.json (this project)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ claude mcp add tmux -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.claude.json (this project)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ claude mcp add tmux -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.claude.json (this project)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ claude mcp add tmux --scope user -- libtmux-mcp

Config file: ~/.claude.json (all projects)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ claude mcp add tmux --scope user -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.claude.json (all projects)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ claude mcp add tmux --scope user -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.claude.json (all projects)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ claude mcp add tmux --scope project -- libtmux-mcp

Config file: .mcp.json (in repo, version-controlled)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ claude mcp add tmux --scope project -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .mcp.json (in repo, version-controlled)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ claude mcp add tmux --scope project -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .mcp.json (in repo, version-controlled)

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["libtmux-mcp"]
        }
    }
}

Config file: claude_desktop_config.json

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["--exclude-newer", "P7D", "--exclude-newer-package", "libtmux-mcp=2099-01-01", "libtmux-mcp"]
        }
    }
}

Config file: claude_desktop_config.json

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["libtmux-mcp"],
            "env": { "UV_NO_CONFIG": "1" }
        }
    }
}

Config file: claude_desktop_config.json

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

Config file: claude_desktop_config.json

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: claude_desktop_config.json

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: claude_desktop_config.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

Config file: claude_desktop_config.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: claude_desktop_config.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: claude_desktop_config.json

With uvx installed:

$ codex mcp add tmux -- uvx libtmux-mcp

Config file: ~/.codex/config.toml

With uvx installed:

$ codex mcp add tmux -- uvx --exclude-newer P7D \
    --exclude-newer-package libtmux-mcp=2099-01-01 libtmux-mcp

Config file: ~/.codex/config.toml

With uvx installed:

$ codex mcp add tmux -- uvx --no-config libtmux-mcp

Config file: ~/.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.

[mcp_servers.tmux]
command = "uvx"
args = ["libtmux-mcp"]

Config file: .codex/config.toml (in repo)

With uvx installed:

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

[mcp_servers.tmux]
command = "uvx"
args = ["--exclude-newer", "P7D", "--exclude-newer-package", "libtmux-mcp=2099-01-01", "libtmux-mcp"]

Config file: .codex/config.toml (in repo)

With uvx installed:

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

[mcp_servers.tmux]
command = "uvx"
args = ["libtmux-mcp"]
env = { UV_NO_CONFIG = "1" }

Config file: .codex/config.toml (in repo)

With pipx installed:

$ codex mcp add tmux -- pipx run libtmux-mcp

Config file: ~/.codex/config.toml

With pipx installed:

$ codex mcp add tmux -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.codex/config.toml

With pipx installed:

$ codex mcp add tmux -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.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.

[mcp_servers.tmux]
command = "pipx"
args = ["run", "libtmux-mcp"]

Config file: .codex/config.toml (in repo)

With pipx installed:

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

[mcp_servers.tmux]
command = "pipx"
args = ["run", "libtmux-mcp"]

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .codex/config.toml (in repo)

With pipx installed:

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

[mcp_servers.tmux]
command = "pipx"
args = ["run", "libtmux-mcp"]

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .codex/config.toml (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ codex mcp add tmux -- libtmux-mcp

Config file: ~/.codex/config.toml

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ codex mcp add tmux -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.codex/config.toml

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ codex mcp add tmux -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.codex/config.toml

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

[mcp_servers.tmux]
command = "libtmux-mcp"

Config file: .codex/config.toml (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

[mcp_servers.tmux]
command = "libtmux-mcp"

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .codex/config.toml (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

[mcp_servers.tmux]
command = "libtmux-mcp"

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .codex/config.toml (in repo)

With uvx installed:

$ gemini mcp add --scope user tmux uvx -- libtmux-mcp

Config file: ~/.gemini/settings.json

With uvx installed:

$ gemini mcp add --scope user tmux uvx -- --exclude-newer P7D \
    --exclude-newer-package libtmux-mcp=2099-01-01 libtmux-mcp

Config file: ~/.gemini/settings.json

With uvx installed:

$ gemini mcp add --scope user tmux uvx -- --no-config libtmux-mcp

Config file: ~/.gemini/settings.json

With uvx installed:

$ gemini mcp add --scope project tmux uvx -- libtmux-mcp

Config file: .gemini/settings.json (in repo)

With uvx installed:

$ gemini mcp add --scope project tmux uvx -- --exclude-newer P7D \
    --exclude-newer-package libtmux-mcp=2099-01-01 libtmux-mcp

Config file: .gemini/settings.json (in repo)

With uvx installed:

$ gemini mcp add --scope project tmux uvx -- --no-config libtmux-mcp

Config file: .gemini/settings.json (in repo)

With pipx installed:

$ gemini mcp add --scope user tmux pipx -- run libtmux-mcp

Config file: ~/.gemini/settings.json

With pipx installed:

$ gemini mcp add --scope user tmux pipx -- run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.gemini/settings.json

With pipx installed:

$ gemini mcp add --scope user tmux pipx -- run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.gemini/settings.json

With pipx installed:

$ gemini mcp add --scope project tmux pipx -- run libtmux-mcp

Config file: .gemini/settings.json (in repo)

With pipx installed:

$ gemini mcp add --scope project tmux pipx -- run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .gemini/settings.json (in repo)

With pipx installed:

$ gemini mcp add --scope project tmux pipx -- run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .gemini/settings.json (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ gemini mcp add --scope user tmux libtmux-mcp

Config file: ~/.gemini/settings.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ gemini mcp add --scope user tmux libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.gemini/settings.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ gemini mcp add --scope user tmux libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.gemini/settings.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ gemini mcp add --scope project tmux libtmux-mcp

Config file: .gemini/settings.json (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ gemini mcp add --scope project tmux libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .gemini/settings.json (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ gemini mcp add --scope project tmux libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .gemini/settings.json (in repo)

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["libtmux-mcp"]
        }
    }
}

Config file: .cursor/mcp.json (in repo)

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["--exclude-newer", "P7D", "--exclude-newer-package", "libtmux-mcp=2099-01-01", "libtmux-mcp"]
        }
    }
}

Config file: .cursor/mcp.json (in repo)

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["libtmux-mcp"],
            "env": { "UV_NO_CONFIG": "1" }
        }
    }
}

Config file: .cursor/mcp.json (in repo)

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["libtmux-mcp"]
        }
    }
}

Config file: ~/.cursor/mcp.json

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["--exclude-newer", "P7D", "--exclude-newer-package", "libtmux-mcp=2099-01-01", "libtmux-mcp"]
        }
    }
}

Config file: ~/.cursor/mcp.json

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["libtmux-mcp"],
            "env": { "UV_NO_CONFIG": "1" }
        }
    }
}

Config file: ~/.cursor/mcp.json

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

Config file: .cursor/mcp.json (in repo)

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .cursor/mcp.json (in repo)

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .cursor/mcp.json (in repo)

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

Config file: ~/.cursor/mcp.json

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.cursor/mcp.json

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.cursor/mcp.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

Config file: .cursor/mcp.json (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .cursor/mcp.json (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: .cursor/mcp.json (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

Config file: ~/.cursor/mcp.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.cursor/mcp.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.cursor/mcp.json

With uvx installed:

$ grok mcp add --scope user tmux -- uvx libtmux-mcp

Config file: ~/.grok/config.toml

With uvx installed:

$ grok mcp add --scope user tmux -- uvx --exclude-newer P7D \
    --exclude-newer-package libtmux-mcp=2099-01-01 libtmux-mcp

Config file: ~/.grok/config.toml

With uvx installed:

$ grok mcp add --scope user tmux -- uvx --no-config libtmux-mcp

Config file: ~/.grok/config.toml

With uvx installed:

$ grok mcp add --scope project tmux -- uvx libtmux-mcp

Config file: ./.grok/config.toml (in repo)

With uvx installed:

$ grok mcp add --scope project tmux -- uvx --exclude-newer P7D \
    --exclude-newer-package libtmux-mcp=2099-01-01 libtmux-mcp

Config file: ./.grok/config.toml (in repo)

With uvx installed:

$ grok mcp add --scope project tmux -- uvx --no-config libtmux-mcp

Config file: ./.grok/config.toml (in repo)

With pipx installed:

$ grok mcp add --scope user tmux -- pipx run libtmux-mcp

Config file: ~/.grok/config.toml

With pipx installed:

$ grok mcp add --scope user tmux -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.grok/config.toml

With pipx installed:

$ grok mcp add --scope user tmux -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.grok/config.toml

With pipx installed:

$ grok mcp add --scope project tmux -- pipx run libtmux-mcp

Config file: ./.grok/config.toml (in repo)

With pipx installed:

$ grok mcp add --scope project tmux -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ./.grok/config.toml (in repo)

With pipx installed:

$ grok mcp add --scope project tmux -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ./.grok/config.toml (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ grok mcp add --scope user tmux -- libtmux-mcp

Config file: ~/.grok/config.toml

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ grok mcp add --scope user tmux -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.grok/config.toml

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ grok mcp add --scope user tmux -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.grok/config.toml

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ grok mcp add --scope project tmux -- libtmux-mcp

Config file: ./.grok/config.toml (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ grok mcp add --scope project tmux -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ./.grok/config.toml (in repo)

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ grok mcp add --scope project tmux -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ./.grok/config.toml (in repo)

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["libtmux-mcp"]
        }
    }
}

Config file: ~/.gemini/config/mcp_config.json

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["--exclude-newer", "P7D", "--exclude-newer-package", "libtmux-mcp=2099-01-01", "libtmux-mcp"]
        }
    }
}

Config file: ~/.gemini/config/mcp_config.json

With uvx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "uvx",
            "args": ["libtmux-mcp"],
            "env": { "UV_NO_CONFIG": "1" }
        }
    }
}

Config file: ~/.gemini/config/mcp_config.json

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

Config file: ~/.gemini/config/mcp_config.json

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.gemini/config/mcp_config.json

With pipx installed:

{
    "mcpServers": {
        "tmux": {
            "command": "pipx",
            "args": ["run", "libtmux-mcp"]
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.gemini/config/mcp_config.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

Config file: ~/.gemini/config/mcp_config.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.gemini/config/mcp_config.json

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then use this config:

{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.gemini/config/mcp_config.json

With uvx installed:

$ opencode mcp add tmux -- uvx libtmux-mcp

Config file: ~/.config/opencode/opencode.jsonc

With uvx installed:

$ opencode mcp add tmux -- uvx --exclude-newer P7D \
    --exclude-newer-package libtmux-mcp=2099-01-01 libtmux-mcp

Config file: ~/.config/opencode/opencode.jsonc

With uvx installed:

$ opencode mcp add tmux -- uvx --no-config libtmux-mcp

Config file: ~/.config/opencode/opencode.jsonc

With pipx installed:

$ opencode mcp add tmux -- pipx run libtmux-mcp

Config file: ~/.config/opencode/opencode.jsonc

With pipx installed:

$ opencode mcp add tmux -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.config/opencode/opencode.jsonc

With pipx installed:

$ opencode mcp add tmux -- pipx run libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.config/opencode/opencode.jsonc

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ opencode mcp add tmux -- libtmux-mcp

Config file: ~/.config/opencode/opencode.jsonc

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ opencode mcp add tmux -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.config/opencode/opencode.jsonc

Install the packages first:

$ pip install --user --upgrade libtmux libtmux-mcp

Then register:

$ opencode mcp add tmux -- libtmux-mcp

pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`.

Config file: ~/.config/opencode/opencode.jsonc

Embed the server in a program
tests/test_window_tools.py
from fastmcp import Client
from libtmux_mcp.server import build_mcp_server
window = mcp_session.active_window
async def _call() -> t.Any:
async with Client(build_mcp_server()) as client:
return await client.call_tool(
"list_panes",
{
"window_id": window.window_id,
"socket_name": mcp_server.socket_name,
},
raise_on_error=False,
)
result = asyncio.run(_call())

Excerpt of tests/test_window_tools.py, which uv run py.test runs in the repository's CI (.github/workflows/tests.yml).

Workspace Manager

Main-horizontal layout

The main-horizontal layout gives the first pane the top of the window and splits the rest below it.

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"
{
"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\""
}
]
}
]
}
]
}
Window 0, test: 3 panes, main-horizontal❯ vim❯ echo "hey"❯ echo "moo"
layout main-horizontal

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).

Short-hand panes

A pane can be one command written as a string, and a command list can be one string.

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
{
"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"
]
}
]
}
Window 0, focused window: 3 panes, main-horizontal❯ cd ~❯ cd /usr❯ cd ~❯ echo "moo"❯ top
layout main-horizontal
Window 1, window 2: 3 panes, even-vertical❯ top❯ echo "hey"❯ echo "moo"
no layout set
Window 2, window 3: 3 panes, even-vertical❯ cd /
no layout set

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).

Two panes

A window of two panes.

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
{
"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"
}
]
}
]
}
]
}
Window 0, editor: 2 panes, main-vertical❯ vim❯ echo "hey"
layout main-vertical
Window 1, logging: 1 pane, even-vertical❯ tail | echo 'hi'
no layout set
Window 2, test: 1 pane, even-vertical❯ htop
no layout set

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).

Setup before each pane

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"
]
}
]
}
]
}
Window 0, editor: 3 panes, even-vertical❯ vim❯ :Ex❯ cd /usr
no layout set
Window 1, logging: 2 panes, even-vertical❯ top❯ emacs
no layout set

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

environment sets variables for a session, a window or a 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
# 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"
}
}
]
}
]
}
Window 0, no_overrides: 1 pane, even-vertical
no layout set
Window 1, window_overrides: 1 pane, even-vertical
no layout set
Window 2, pane_overrides: 1 pane, even-vertical
no layout set
Window 3, both_overrides: 2 panes, even-vertical
no layout set
Window 4, both_overrides_on_first_pane: 1 pane, even-vertical
no layout set

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

start_directory chooses where a session, a window or a pane starts.

session_name: sample workspace
windows:
- panes:
- start_directory: /usr
- start_directory: /etc
{
"session_name": "sample workspace",
"windows": [
{
"panes": [
{
"start_directory": "/usr"
},
{
"start_directory": "/etc"
}
]
}
]
}
Window 0: 2 panes, even-vertical
no layout set

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).

Blank panes

An empty entry, null, pane or blank opens a pane with no command.

session_name: Blank pane test
windows:
# 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"
}
]
}
]
}
Window 0, Blank pane test: 3 panes, even-vertical
no layout set
Window 1, More blank panes: 3 panes, even-vertical
no layout set
Window 2, Empty string (return): 3 panes, even-vertical
no layout set
Window 3, Blank with options: 2 panes, even-vertical
no layout set

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).

Install tmuxp

The workspace package is separate from the core library.

$ uv tool install tmuxp

Installs tmuxp in an isolated Python environment. Run tmuxp load ./workspace.yaml.

$ uvx tmuxp --help

Runs without a permanent installation. Replace --help with load ./workspace.yaml to load a workspace.

$ pipx install tmuxp

Installs the tmuxp command in an isolated Python environment.

Build the workspace from a program
src/tmuxp/workspace/builder/classic.py
>>> 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, which uv run py.test runs in the repository's CI (.github/workflows/tests.yml).

Packages and integrations

API references

All Python versions and install instructions

Esc

Type to search.

Reference previewOpen reference