libtmux Reference MCP Search

C++

C++

Drive a real tmux from C++.

libtmux-cxx

Install

$ vcpkg install libtmux-cxx

Quickstart

// No tmux failure is thrown. Every call answers with a value that is either
// the result or the reason there isn't one.
const auto sessions = server.sessions();
if (!sessions.has_value()) {
std::fprintf(stderr, "%s\n", sessions.error().diagnostic.c_str());
return 1;
}
for (const libtmux::Session& session : *sessions) {
std::printf("%s has %lld window(s)\n", std::string{session.name()}.c_str(),
session.window_count());
}

server in the code above comes from Server::from_env() (inside tmux), Server::at_socket_name() , Server::at_socket_path() , or Server::at_default() — the README's own words for how to get one.

The README's Quickstart, "Connect and look around" — lives in examples/05-readme.cpp, and tools/docs/check_readme.py fails the build if the two ever disagree.

API References

Read on

Esc

Type to search.