API-reference
cmux tilbyder både et CLI-værktøj og en Unix socket til programmatisk styring. Alle kommandoer er tilgængelige via begge grænseflader.
Socket
| Build | Sti |
|---|---|
| Release | /tmp/cmux.sock |
| Debug | /tmp/cmux-debug.sock |
| Tagget debug build | /tmp/cmux-debug-<tag>.sock |
Overskriv med CMUX_SOCKET_PATH-miljøvariablen. Send én linjetermineret JSON-anmodning per kald:
{"id":"req-1","method":"workspace.list","params":{}}
// Response:
{"id":"req-1","ok":true,"result":{"workspaces":[...]}}{"command":"..."} understøttes ikke.Adgangstilstande
| Tilstand | Beskrivelse | Sådan aktiveres |
|---|---|---|
| Off | Socket deaktiveret | Indstillinger-UI eller CMUX_SOCKET_MODE=off |
| cmux processes only | Kun processer startet inde i cmux-terminaler kan forbinde. | Standardtilstand i Indstillinger-UI |
| allowAll | Tillad enhver lokal proces at forbinde (ingen ancestry-kontrol). | Kun miljøvariabel-override: CMUX_SOCKET_MODE=allowAll |
CLI-indstillinger
| Flag | Beskrivelse |
|---|---|
--socket PATH | Brugerdefineret socketsti |
--json | Output i JSON-format |
--window ID | Målret et specifikt vindue |
--workspace ID | Målret et specifikt workspace |
--surface ID | Målret en specifik surface |
--id-format refs|uuids|both | Styr ID-format i JSON-output |
Workspace-kommandoer
list-workspaces
List alle åbne workspaces.
cmux list-workspaces
cmux list-workspaces --json{"id":"ws-list","method":"workspace.list","params":{}}new-workspace
Opret et nyt workspace.
cmux new-workspace{"id":"ws-new","method":"workspace.create","params":{}}select-workspace
Skift til et specifikt workspace.
cmux select-workspace --workspace <id>{"id":"ws-select","method":"workspace.select","params":{"workspace_id":"<id>"}}current-workspace
Hent det aktuelt aktive workspace.
cmux current-workspace
cmux current-workspace --json{"id":"ws-current","method":"workspace.current","params":{}}close-workspace
Luk et workspace.
cmux close-workspace --workspace <id>{"id":"ws-close","method":"workspace.close","params":{"workspace_id":"<id>"}}Opdelingskommandoer
new-split
Opret et nyt opdelt panel. Retninger: left, right, up, down.
cmux new-split right
cmux new-split down{"id":"split-new","method":"surface.split","params":{"direction":"right"}}list-surfaces
List alle surfaces i det aktuelle workspace.
cmux list-surfaces
cmux list-surfaces --json{"id":"surface-list","method":"surface.list","params":{}}focus-surface
Fokusér en specifik surface.
cmux focus-surface --surface <id>{"id":"surface-focus","method":"surface.focus","params":{"surface_id":"<id>"}}Inputkommandoer
send
Send tekstinput til den fokuserede terminal.
cmux send "echo hello"
cmux send "ls -la\n"{"id":"send-text","method":"surface.send_text","params":{"text":"echo hello\n"}}send-key
Send et tastetryk. Taster: enter, tab, escape, backspace, delete, up, down, left, right.
cmux send-key enter{"id":"send-key","method":"surface.send_key","params":{"key":"enter"}}send-surface
Send tekst til en specifik surface.
cmux send-surface --surface <id> "command"{"id":"send-surface","method":"surface.send_text","params":{"surface_id":"<id>","text":"command"}}send-key-surface
Send et tastetryk til en specifik surface.
cmux send-key-surface --surface <id> enter{"id":"send-key-surface","method":"surface.send_key","params":{"surface_id":"<id>","key":"enter"}}Notifikationskommandoer
notify
Send en notifikation.
cmux notify --title "Title" --body "Body"
cmux notify --title "T" --subtitle "S" --body "B"{"id":"notify","method":"notification.create","params":{"title":"Title","subtitle":"S","body":"Body"}}list-notifications
List alle notifikationer.
cmux list-notifications
cmux list-notifications --json{"id":"notif-list","method":"notification.list","params":{}}clear-notifications
Ryd alle notifikationer.
cmux clear-notifications{"id":"notif-clear","method":"notification.clear","params":{}}Sidebar-metadatakommandoer
Sæt statuspiller, fremskridtsbjælker og logposter i sidebaren for ethvert workspace. Nyttigt til build-scripts, CI-integrationer og AI-kodningsagenter der vil vise tilstand med et blik.
set-status
Sæt en sidebar-statuspille. Brug en unik nøgle så forskellige værktøjer kan håndtere deres egne poster.
cmux set-status build "compiling" --icon hammer --color "#ff9500"
cmux set-status deploy "v1.2.3" --workspace workspace:2set_status build compiling --icon=hammer --color=#ff9500 --tab=<workspace-uuid>clear-status
Fjern en sidebar-statuspost ved nøgle.
cmux clear-status buildclear_status build --tab=<workspace-uuid>list-status
List alle sidebar-statusposter for et workspace.
cmux list-statuslist_status --tab=<workspace-uuid>set-progress
Sæt en fremskridtsbjælke i sidebaren (0.0 til 1.0).
cmux set-progress 0.5 --label "Building..."
cmux set-progress 1.0 --label "Done"set_progress 0.5 --label=Building... --tab=<workspace-uuid>clear-progress
Ryd sidebar-fremskridtsbjælken.
cmux clear-progressclear_progress --tab=<workspace-uuid>log
Tilføj en logpost til sidebaren. Niveauer: info, progress, success, warning, error.
cmux log "Build started"
cmux log --level error --source build "Compilation failed"
cmux log --level success -- "All 42 tests passed"log --level=error --source=build --tab=<workspace-uuid> -- Compilation failedclear-log
Ryd alle sidebar-logposter.
cmux clear-logclear_log --tab=<workspace-uuid>list-log
List sidebar-logposter.
cmux list-log
cmux list-log --limit 5list_log --limit=5 --tab=<workspace-uuid>sidebar-state
Dump al sidebar-metadata (cwd, git branch, porte, status, fremskridt, logs).
cmux sidebar-state
cmux sidebar-state --workspace workspace:2sidebar_state --tab=<workspace-uuid>Hjælpekommandoer
ping
Tjek om cmux kører og er responsiv.
cmux ping{"id":"ping","method":"system.ping","params":{}}
// Response: {"id":"ping","ok":true,"result":{"pong":true}}capabilities
List tilgængelige socket-metoder og aktuel adgangstilstand.
cmux capabilities
cmux capabilities --json{"id":"caps","method":"system.capabilities","params":{}}identify
Vis fokuseret vindue/workspace/panel/surface-kontekst.
cmux identify
cmux identify --json{"id":"identify","method":"system.identify","params":{}}Miljøvariabler
| Variabel | Beskrivelse |
|---|---|
CMUX_SOCKET_PATH | Overskriv socketstien brugt af CLI og integrationer |
CMUX_SOCKET_ENABLE | Tving aktivering/deaktivering af socket (1/0, true/false, on/off) |
CMUX_SOCKET_MODE | Overskriv adgangstilstand (cmuxOnly, allowAll, off). Accepterer også cmux-only/cmux_only og allow-all/allow_all |
CMUX_WORKSPACE_ID | Auto-sat: nuværende workspace-ID |
CMUX_SURFACE_ID | Auto-sat: nuværende surface-ID |
TERM_PROGRAM | Sat til ghostty |
TERM | Sat til xterm-ghostty |
Detektering af cmux
# Prefer explicit socket path if set
SOCK="${CMUX_SOCKET_PATH:-/tmp/cmux.sock}"
[ -S "$SOCK" ] && echo "Socket available"
# Check for the CLI
command -v cmux &>/dev/null && echo "cmux available"
# In cmux-managed terminals these are auto-set
[ -n "${CMUX_WORKSPACE_ID:-}" ] && [ -n "${CMUX_SURFACE_ID:-}" ] && echo "Inside cmux surface"
# Distinguish from regular Ghostty
[ "$TERM_PROGRAM" = "ghostty" ] && [ -n "${CMUX_WORKSPACE_ID:-}" ] && echo "In cmux"Eksempler
Python-klient
import json
import os
import socket
SOCKET_PATH = os.environ.get("CMUX_SOCKET_PATH", "/tmp/cmux.sock")
def rpc(method, params=None, req_id=1):
payload = {"id": req_id, "method": method, "params": params or {}}
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
sock.connect(SOCKET_PATH)
sock.sendall(json.dumps(payload).encode("utf-8") + b"\n")
return json.loads(sock.recv(65536).decode("utf-8"))
# List workspaces
print(rpc("workspace.list", req_id="ws"))
# Send notification
print(rpc(
"notification.create",
{"title": "Hello", "body": "From Python!"},
req_id="notify"
))Shell-script
#!/bin/bash
SOCK="${CMUX_SOCKET_PATH:-/tmp/cmux.sock}"
cmux_cmd() {
printf "%s\n" "$1" | nc -U "$SOCK"
}
cmux_cmd '{"id":"ws","method":"workspace.list","params":{}}'
cmux_cmd '{"id":"notify","method":"notification.create","params":{"title":"Done","body":"Task complete"}}'Build-script med notifikation
#!/bin/bash
npm run build
if [ $? -eq 0 ]; then
cmux notify --title "✓ Build Success" --body "Ready to deploy"
else
cmux notify --title "✗ Build Failed" --body "Check the logs"
fi