Skip to main content

tmux-ctl

HTTP API for tmux. Control sessions, windows, panes. Read terminal state.

Install

# PyPI
pip install tmux-api

# pipx (isolated)
pipx install tmux-api

# Homebrew
brew install MarkAtwood/tap/tmux-api

# Nix
nix run github:MarkAtwood/tmux-ctl

Requires tmux to be installed.

Run

tmux-api                    # 127.0.0.1:8765
tmux-api --port 9000        # custom port
tmux-api --host 0.0.0.0     # listen on all interfaces

Connects to your default tmux socket.

API

/docs for Swagger UI. /openapi.json for spec.

Targets: windows take @id or session:index, panes take %id or session:window.pane.

Sessions

GET    /sessions
POST   /sessions              {name, command?, width?, height?}
GET    /sessions/{name}
DELETE /sessions/{name}
POST   /sessions/{name}/rename {new_name}
POST   /sessions/{name}/windows {name?, command?}

Windows

GET    /windows
GET    /windows/{target}
DELETE /windows/{target}
POST   /windows/{target}/rename {new_name}
POST   /windows/{target}/split  {vertical?, command?, size?}

Panes

GET    /panes
GET    /panes/{target}
DELETE /panes/{target}
POST   /panes/{target}/split   {vertical?, command?, size?}
POST   /panes/{target}/resize  {width?, height?}

I/O

GET    /panes/{target}/output  ?lines=100
POST   /panes/{target}/input   {keys, literal?, enter?}
POST   /panes/{target}/mouse   {x, y, button, action}
POST   /panes/{target}/capture {start_line?, end_line?, start_col?, end_col?}
GET    /panes/{target}/search  ?pattern=regex
POST   /panes/{target}/wait    {pattern, timeout?, interval?}

Terminal State

GET    /panes/{target}/terminal   modes, scroll region, tabs
GET    /panes/{target}/screen     visible screen, ?colors=true for ANSI
GET    /panes/{target}/grid       cell-level: char, fg, bg, attrs
GET    /panes/{target}/lines      with prompt/output flags (OSC 133)
GET    /panes/{target}/commands   shell commands grouped with output
GET    /panes/{target}/widgets    box-drawing regions (curses apps)
GET    /panes/{target}/prompt     shell prompt detection

Buffers, Clients, Options

GET    /buffers
GET    /buffers/{name}
POST   /buffers           {content, name?}
DELETE /buffers/{name}

GET    /clients

GET    /sessions/{name}/options
PUT    /sessions/{name}/options/{opt} {value}
GET    /sessions/{name}/env
PUT    /sessions/{name}/env/{var}     {value}
DELETE /sessions/{name}/env/{var}

Same pattern for /windows/{target}/options and /panes/{target}/options.

Examples

# list sessions
curl localhost:8765/sessions

# create session
curl -X POST localhost:8765/sessions -H 'content-type: application/json' \
  -d '{"name":"work"}'

# send keys
curl -X POST localhost:8765/panes/work:0.0/input -H 'content-type: application/json' \
  -d '{"keys":"echo hello","enter":true}'

# read output
curl 'localhost:8765/panes/work:0.0/output?lines=10'

# wait for prompt
curl -X POST localhost:8765/panes/work:0.0/wait -H 'content-type: application/json' \
  -d '{"pattern":"\\$\\s*$","timeout":5}'

# kill session
curl -X DELETE localhost:8765/sessions/work

License

MIT

Metadata

Release files for tmux-api 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tmux-api 0.1.0
File Size Uploaded Provenance Actions
tmux_api-0.1.0.tar.gz 11.2 kB Without provenance Details for tmux_api-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tmux-api 0.1.0
File Interpreter ABI Platform Actions
tmux_api-0.1.0-py3-none-any.whl Python 3 none any Details for tmux_api-0.1.0-py3-none-any.whl

Total release size: 23.0 kB

Release files / tmux_api-0.1.0.tar.gz

Download URL tmux_api-0.1.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
68ce151a506076b0e974de6db3e8819904e7480a4b8bf89ce84e7582cb997650
BLAKE2b-256 checksum
How to use checksums
04cb88781a5526fa2e826b60e9f67ddee81fb1521d4b25138cad0b923cfc1c0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / tmux_api-0.1.0-py3-none-any.whl

Download URL tmux_api-0.1.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab319ba1208969b78b235d4647102d80a1a9483bb7641ec692df71ce462d2469
BLAKE2b-256 checksum
How to use checksums
14ac002d0026b7007c624ba37e247667da2ab815ba4d315b6af56cf3b4bf5731
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for tmux-api 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page