Skip to main content

Crate ztmux_core

Crate ztmux_core 

Source
Expand description

ztmux-core — a native tmux client engine.

Speaks tmux’s client/server wire protocol (OpenBSD imsg framing, protocol version 8) directly to the server socket — no tmux subprocess, no control mode. Ported from tmux 3.6 sources.

Layers:

  • transport — the wire client: command, socket_path, TmuxOutput.
  • proc — read a pane’s running command line (libproc / /proc).
  • ops — session tree, search corpus, broadcast list + send_keys, synchronize-panes, focus, dashboard summary — all returning serde_json::Value.
  • snapshot — native session save/restore (a tmux-resurrect replacement), parameterized by the storage directory so any app picks its own.

Intended to be wired into GUI apps: each calls these functions and renders the JSON in its own frontend.

Re-exports§

pub use transport::command;
pub use transport::socket_path;
pub use transport::TmuxOutput;

Modules§

ops
High-level tmux operations over the wire protocol — the data + commands a GUI app needs: the session tree (with pane previews), a cross-pane search corpus, the broadcast pane list + send-keys, synchronize-panes, focus, and a dashboard summary. Every function returns plain serde_json::Value / runs fire-and-forget, so any frontend can render it. Unix-only; non-unix builds get empty stubs.
proc
Process inspection: the full command line running in a tmux pane (the shell’s foreground child), mirroring tmux-resurrect’s pgrep -lf -P <pane_pid> — natively, no subprocess. macOS uses libproc proc_listpids + sysctl KERN_PROCARGS2; other Unix reads /proc.
snapshot
Native tmux session save/restore (a tmux-resurrect replacement). Snapshots are stored under a caller-supplied directory: <dir>/<name>.json plus an optional <dir>/<name>.contents/ of per-pane scrollback. Restore rebuilds the tree over the wire protocol with exact select-layout geometry.
transport
Native tmux client: speaks tmux’s wire protocol directly to the server’s Unix socket — no tmux subprocess. zterminal becomes a first-class tmux client, so it can run any tmux command and read its output (giving full control of the running server from the GUI).