Skip to main content

Crate tmux_companion

Crate tmux_companion 

Source
Expand description

tmux-companion: one daemon that draws the tmux status bar, and the tools around a tmux server that a plugin manager used to provide.

Most people want the binary:

cargo install --locked tmux-companion
tmux-companion doctor

and the manual, man tmux-companion, or the README for what it does.

§The library

The same crate is a library, for a program that wants a part of what the binary does without running the binary for it. Three parts are meant to be used from outside, and the documentation shows only those:

use tmux_companion::segments::git::GitStatus;

let porcelain = "\
# branch.oid 1f2e3d4c5b6a
# branch.head main
# branch.upstream origin/main
# branch.ab +2 -0
1 .M N... 100644 100644 100644 aaaa bbbb src/lib.rs
? notes.txt
";
let status = GitStatus::parse_porcelain_v2(porcelain);
assert_eq!(status.branch, "main");
assert_eq!(status.ahead, 2);
assert_eq!(status.unstaged.modified, 1);
assert_eq!(status.untracked, 1);

§Stability

The parts above follow semver: before 1.0 a breaking change to them bumps the minor version and has a line in the changelog. Everything else in the crate is the binary’s own code. It’s public so the integration tests can link against it, it’s hidden from these docs and it changes whenever the binary needs it to, in any release.

The library pulls in everything the binary uses, tokio and ratatui included; there are no feature flags to trim it yet.

Modules§

daemon
Asking a running tmux-companion daemon for a segment, from another program.
keyroute
keys that tmux and the apps in its panes both want: what each layer binds, and where they collide
proto
The daemon’s protocol: one JSON Request line in, one JSON Response line out, and one arguments struct per command.
segments
One module per thing the status bar can draw.
sessions
Snapshots of the whole tmux server, and the generations they are kept in.
tmux
Everything that knows about tmux’s own formatting language.