API-Referenz
cmux bietet sowohl ein CLI-Werkzeug als auch einen Unix-Socket für programmatische Steuerung. Jeder Befehl ist über beide Schnittstellen verfügbar.
Socket
| Build | Pfad |
|---|---|
| Release | /tmp/cmux.sock |
| Debug | /tmp/cmux-debug.sock |
| Getaggter Debug-Build | /tmp/cmux-debug-<tag>.sock |
Überschreiben mit der Umgebungsvariable CMUX_SOCKET_PATH. Senden Sie eine JSON-Anfrage pro Aufruf, mit Zeilenumbruch am Ende:
{"id":"req-1","method":"workspace.list","params":{}}
// Response:
{"id":"req-1","ok":true,"result":{"workspaces":[...]}}{"command":"..."} werden nicht unterstützt.Zugriffsmodi
| Modus | Beschreibung | Aktivierung |
|---|---|---|
| Off | Socket deaktiviert | Einstellungs-UI oder CMUX_SOCKET_MODE=off |
| cmux processes only | Nur Prozesse, die in cmux-Terminals gestartet wurden, können sich verbinden. | Standardmodus in der Einstellungs-UI |
| allowAll | Jeden lokalen Prozess verbinden lassen (keine Herkunftsprüfung). | Nur per Umgebungsvariable: CMUX_SOCKET_MODE=allowAll |
CLI-Optionen
| Flag | Beschreibung |
|---|---|
--socket PATH | Benutzerdefinierter Socket-Pfad |
--json | Ausgabe im JSON-Format |
--window ID | Ein bestimmtes Fenster ansprechen |
--workspace ID | Einen bestimmten Workspace ansprechen |
--surface ID | Eine bestimmte Oberfläche ansprechen |
--id-format refs|uuids|both | ID-Format in der JSON-Ausgabe steuern |
Workspace-Befehle
list-workspaces
Alle geöffneten Workspaces auflisten.
cmux list-workspaces
cmux list-workspaces --json{"id":"ws-list","method":"workspace.list","params":{}}new-workspace
Einen neuen Workspace erstellen.
cmux new-workspace{"id":"ws-new","method":"workspace.create","params":{}}select-workspace
Zu einem bestimmten Workspace wechseln.
cmux select-workspace --workspace <id>{"id":"ws-select","method":"workspace.select","params":{"workspace_id":"<id>"}}current-workspace
Den aktuell aktiven Workspace abrufen.
cmux current-workspace
cmux current-workspace --json{"id":"ws-current","method":"workspace.current","params":{}}close-workspace
Einen Workspace schließen.
cmux close-workspace --workspace <id>{"id":"ws-close","method":"workspace.close","params":{"workspace_id":"<id>"}}Split-Befehle
new-split
Einen neuen geteilten Bereich erstellen. Richtungen: left, right, up, down.
cmux new-split right
cmux new-split down{"id":"split-new","method":"surface.split","params":{"direction":"right"}}list-surfaces
Alle Oberflächen im aktuellen Workspace auflisten.
cmux list-surfaces
cmux list-surfaces --json{"id":"surface-list","method":"surface.list","params":{}}focus-surface
Eine bestimmte Oberfläche fokussieren.
cmux focus-surface --surface <id>{"id":"surface-focus","method":"surface.focus","params":{"surface_id":"<id>"}}Eingabebefehle
send
Texteingabe an das fokussierte Terminal senden.
cmux send "echo hello"
cmux send "ls -la\n"{"id":"send-text","method":"surface.send_text","params":{"text":"echo hello\n"}}send-key
Einen Tastendruck senden. Tasten: 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
Text an eine bestimmte Oberfläche senden.
cmux send-surface --surface <id> "command"{"id":"send-surface","method":"surface.send_text","params":{"surface_id":"<id>","text":"command"}}send-key-surface
Einen Tastendruck an eine bestimmte Oberfläche senden.
cmux send-key-surface --surface <id> enter{"id":"send-key-surface","method":"surface.send_key","params":{"surface_id":"<id>","key":"enter"}}Benachrichtigungsbefehle
notify
Eine Benachrichtigung senden.
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
Alle Benachrichtigungen auflisten.
cmux list-notifications
cmux list-notifications --json{"id":"notif-list","method":"notification.list","params":{}}clear-notifications
Alle Benachrichtigungen löschen.
cmux clear-notifications{"id":"notif-clear","method":"notification.clear","params":{}}Seitenleisten-Metadaten-Befehle
Setzen Sie Status-Pills, Fortschrittsbalken und Log-Einträge in der Seitenleiste für jeden Workspace. Nützlich für Build-Skripte, CI-Integrationen und KI-Coding-Agenten, die den Status auf einen Blick anzeigen möchten.
set-status
Eine Seitenleisten-Status-Pill setzen. Verwenden Sie einen eindeutigen Schlüssel, damit verschiedene Werkzeuge ihre eigenen Einträge verwalten können.
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
Einen Seitenleisten-Status-Eintrag per Schlüssel entfernen.
cmux clear-status buildclear_status build --tab=<workspace-uuid>list-status
Alle Seitenleisten-Status-Einträge für einen Workspace auflisten.
cmux list-statuslist_status --tab=<workspace-uuid>set-progress
Einen Fortschrittsbalken in der Seitenleiste setzen (0.0 bis 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
Den Seitenleisten-Fortschrittsbalken löschen.
cmux clear-progressclear_progress --tab=<workspace-uuid>log
Einen Log-Eintrag zur Seitenleiste hinzufügen. Stufen: 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
Alle Seitenleisten-Log-Einträge löschen.
cmux clear-logclear_log --tab=<workspace-uuid>list-log
Seitenleisten-Log-Einträge auflisten.
cmux list-log
cmux list-log --limit 5list_log --limit=5 --tab=<workspace-uuid>sidebar-state
Alle Seitenleisten-Metadaten ausgeben (cwd, Git-Branch, Ports, Status, Fortschritt, Logs).
cmux sidebar-state
cmux sidebar-state --workspace workspace:2sidebar_state --tab=<workspace-uuid>Hilfsbefehle
ping
Prüfen, ob cmux läuft und reagiert.
cmux ping{"id":"ping","method":"system.ping","params":{}}
// Response: {"id":"ping","ok":true,"result":{"pong":true}}capabilities
Verfügbare Socket-Methoden und aktuellen Zugriffsmodus auflisten.
cmux capabilities
cmux capabilities --json{"id":"caps","method":"system.capabilities","params":{}}identify
Fokussierten Fenster-/Workspace-/Bereichs-/Oberflächen-Kontext anzeigen.
cmux identify
cmux identify --json{"id":"identify","method":"system.identify","params":{}}Umgebungsvariablen
| Variable | Beschreibung |
|---|---|
CMUX_SOCKET_PATH | Den von CLI und Integrationen verwendeten Socket-Pfad überschreiben |
CMUX_SOCKET_ENABLE | Socket aktivieren/deaktivieren erzwingen (1/0, true/false, on/off) |
CMUX_SOCKET_MODE | Zugriffsmodus überschreiben (cmuxOnly, allowAll, off). Akzeptiert auch cmux-only/cmux_only und allow-all/allow_all |
CMUX_WORKSPACE_ID | Automatisch gesetzt: Aktuelle Workspace-ID |
CMUX_SURFACE_ID | Automatisch gesetzt: Aktuelle Oberflächen-ID |
TERM_PROGRAM | Gesetzt auf ghostty |
TERM | Gesetzt auf xterm-ghostty |
cmux erkennen
# 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"Beispiele
Python-Client
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-Skript
#!/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-Skript mit Benachrichtigung
#!/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