tmux_companion/lib.rs
1//! tmux-companion: one daemon that draws the tmux status bar, and the tools
2//! around a tmux server that a plugin manager used to provide.
3//!
4//! Most people want the binary:
5//!
6//! ```sh
7//! cargo install --locked tmux-companion
8//! tmux-companion doctor
9//! ```
10//!
11//! and the manual, `man tmux-companion`, or the
12//! [README](https://github.com/lonkar-org/tmux-companion#readme) for what it
13//! does.
14//!
15//! # The library
16//!
17//! The same crate is a library, for a program that wants a part of what the
18//! binary does without running the binary for it. Three parts are meant to be
19//! used from outside, and the documentation shows only those:
20//!
21//! - **Asking the daemon.** [`daemon::Daemon`] sends one request to a running
22//! `tmux-companion server` and returns its answer, with the request and
23//! response types and each command's arguments in [`proto`]. It's
24//! blocking, needs no async runtime, and never starts or replaces a daemon.
25//! - **Parsing and drawing.** [`segments::git`] parses `git status
26//! --porcelain=v2 --branch` into [`segments::git::GitStatus`] and renders it
27//! as a segment; [`tmux::format`] builds tmux style strings and turns them
28//! into ANSI for a terminal; [`segments::network`] is the arithmetic behind
29//! a transfer rate; [`keyroute::spell`] translates key names from nvim, fzf,
30//! zsh, nano and Claude Code into tmux's spelling. None of these touch tmux
31//! or a socket.
32//! - **Session snapshots.** [`sessions::Snapshot`] is a whole tmux server as
33//! data: [`sessions::capture`] builds one from tmux's own listings,
34//! [`sessions::render`] and [`sessions::parse`] write and read the file
35//! format, [`sessions::store`] keeps generations of them,
36//! [`sessions::portable`] moves one between machines, and
37//! [`sessions::import`] reads what tmux-resurrect saved.
38//!
39//! ```
40//! use tmux_companion::segments::git::GitStatus;
41//!
42//! let porcelain = "\
43//! ## branch.oid 1f2e3d4c5b6a
44//! ## branch.head main
45//! ## branch.upstream origin/main
46//! ## branch.ab +2 -0
47//! 1 .M N... 100644 100644 100644 aaaa bbbb src/lib.rs
48//! ? notes.txt
49//! ";
50//! let status = GitStatus::parse_porcelain_v2(porcelain);
51//! assert_eq!(status.branch, "main");
52//! assert_eq!(status.ahead, 2);
53//! assert_eq!(status.unstaged.modified, 1);
54//! assert_eq!(status.untracked, 1);
55//! ```
56//!
57//! # Stability
58//!
59//! The parts above follow semver: before 1.0 a breaking change to them bumps
60//! the minor version and has a line in the changelog. Everything else in the
61//! crate is the binary's own code. It's public so the integration tests can
62//! link against it, it's hidden from these docs and it changes whenever the
63//! binary needs it to, in any release.
64//!
65//! The library pulls in everything the binary uses, tokio and ratatui
66//! included; there are no feature flags to trim it yet.
67
68#![warn(missing_docs)]
69#![warn(rustdoc::broken_intra_doc_links)]
70
71// ── The library ─────────────────────────────────────────────────────────────
72
73pub mod daemon;
74pub mod keyroute;
75pub mod proto;
76pub mod segments;
77pub mod sessions;
78pub mod tmux;
79
80// ── The binary's own code: public for tests/, hidden, no semver promise ────
81
82#[doc(hidden)]
83pub mod agent;
84#[doc(hidden)]
85pub mod autofetch;
86#[doc(hidden)]
87pub mod autoreload;
88#[doc(hidden)]
89pub mod brief;
90#[doc(hidden)]
91pub mod cache;
92#[doc(hidden)]
93pub mod cheatsheet;
94#[doc(hidden)]
95pub mod chunk;
96#[doc(hidden)]
97pub mod cli;
98#[doc(hidden)]
99pub mod click;
100#[doc(hidden)]
101pub mod client;
102#[doc(hidden)]
103pub mod close;
104#[doc(hidden)]
105pub mod config;
106#[doc(hidden)]
107pub mod dirsource;
108#[doc(hidden)]
109pub mod doctor;
110#[doc(hidden)]
111pub mod earcons;
112#[doc(hidden)]
113pub mod inbox;
114#[doc(hidden)]
115pub mod journal;
116#[doc(hidden)]
117pub mod jump;
118#[doc(hidden)]
119pub mod keys;
120#[doc(hidden)]
121pub mod kill;
122#[doc(hidden)]
123pub mod local;
124#[doc(hidden)]
125pub mod note;
126#[doc(hidden)]
127pub mod notify;
128#[doc(hidden)]
129pub mod online;
130#[doc(hidden)]
131pub mod open;
132#[doc(hidden)]
133pub mod panes;
134#[doc(hidden)]
135pub mod picker;
136#[doc(hidden)]
137pub mod pocket;
138#[doc(hidden)]
139pub mod ports;
140#[doc(hidden)]
141pub mod preview;
142#[doc(hidden)]
143pub mod probe;
144#[doc(hidden)]
145pub mod project;
146#[doc(hidden)]
147pub mod promote;
148#[doc(hidden)]
149pub mod quiet;
150#[doc(hidden)]
151pub mod repofile;
152#[doc(hidden)]
153pub mod restore;
154#[doc(hidden)]
155pub mod run;
156#[doc(hidden)]
157pub mod saved;
158#[doc(hidden)]
159pub mod search;
160#[doc(hidden)]
161pub mod server;
162#[doc(hidden)]
163pub mod setup;
164#[doc(hidden)]
165pub mod shell;
166#[doc(hidden)]
167pub mod tasks;
168#[doc(hidden)]
169pub mod theme;
170#[doc(hidden)]
171pub mod window_names;