Server.windows
tmux scopes window and pane listings to the current session unless asked for every one, so -a is part of the request rather than a caller's responsibility to remember.
Source and package
- Qualified name
-
libtmux::Server:: windows - Namespace
- libtmux
- Declared in
Server- Package
- libtmux-cxx
- Source
- include/libtmux/server.hpp
- Other languages
- Perlmethod Erlangfunction PowerShellcmdlet Juliafunction Elixirfunction Haskell Common Lispfunction PythonRubyLuaTypeScriptRustGoJavaC#SwiftKotlinScalaOCamlfunction F#function Clojurefunction
- [[
C++ nodiscard attributeAsks the compiler to warn when a result is discarded. An explicit cast to void acknowledges that the result is intentionally ignored.]] expected<std::vector <Window>, CommandFailure > windows() const; -
Examples#
List server objects. Read independent snapshots of every session, window, pane, and client. Iterating these vectors makes no further tmux calls. The detached fixture has one session, one window, one pane, and no attached clients. libtmux-cxx is not published to a package registry yet, so this builds it from its repository. Use Clang 18 or newer with libc++, CMake 3.25 or newer, Ninja, Git, and tmux 3.3a or newer on Linux. In an empty directory, fetch the documented library revision:
Terminal window $ git clone https://github.com/libtmux/libtmux-cxx.git libtmux-source && \git -C libtmux-source checkout 542fdc204ff3cfa56f5484327cda0c69bad2307dBuild and install the C++23 library and its public testing component into this directory:
Terminal window $ cmake -S libtmux-source -B libtmux-build -G Ninja \-DCMAKE_TOOLCHAIN_FILE="$PWD/libtmux-source/cmake/toolchains/clang-libcxx.cmake" \-DCMAKE_C_COMPILER=clang \-DCMAKE_CXX_COMPILER=clang++ \-DCMAKE_BUILD_TYPE=Release \-DLIBTMUX_BUILD_TESTS=OFF \-DLIBTMUX_BUILD_EXAMPLES=OFF \-DLIBTMUX_BUILD_TESTING_LIBRARY=ON && \cmake --build libtmux-build --parallel 2 && \cmake --install libtmux-build --prefix "$PWD/libtmux-prefix"Save this complete consumer project as
CMakeLists.txt: View sourcecmake_minimum_required(VERSION 3.25)project(libtmux_api_example LANGUAGES CXX)find_package(libtmux REQUIRED COMPONENTS testing)add_executable(api_example main.cpp)target_link_libraries(api_example PRIVATE libtmux::libtmux libtmux::testing)Save this complete program as
main.cpp.ScopedTmuxServerowns a private daemon and stops it when the program exits. Ordinary applications useServerfor their own socket; these examples use the fixture until setup moves to ordinary server objects. View source#include <cstdio>#include <libtmux/libtmux.hpp>#include <libtmux/testing/scoped_server.hpp>int main() {// The fixture owns this private server and cleans it up on every return path.auto fixture = libtmux::test::ScopedTmuxServer::start({.session_name = "api",.socket_namespace = libtmux::test::SocketNamespace::consumer("api"),});if (!fixture.has_value()) {std::fprintf(stderr, "%s\n", fixture.error().c_str());return 1;}auto server = libtmux::Server::at_socket_path(fixture->socket_path());if (!server.has_value()) {std::fprintf(stderr, "%s\n", server.error().diagnostic.c_str());return 1;}const auto sessions = server->sessions();const auto windows = server->windows();const auto panes = server->panes();const auto clients = server->clients();if (!sessions.has_value()) {std::fprintf(stderr, "%s\n", sessions.error().diagnostic.c_str());return 1;}if (!windows.has_value()) {std::fprintf(stderr, "%s\n", windows.error().diagnostic.c_str());return 1;}if (!panes.has_value()) {std::fprintf(stderr, "%s\n", panes.error().diagnostic.c_str());return 1;}if (!clients.has_value()) {std::fprintf(stderr, "%s\n", clients.error().diagnostic.c_str());return 1;}if (sessions->size() != 1 || windows->size() != 1 || panes->size() != 1 ||!clients->empty()) {std::fputs("unexpected detached server contents\n", stderr);return 1;}std::printf("sessions=%zu windows=%zu panes=%zu clients=%zu\n", sessions->size(),windows->size(), panes->size(), clients->size());return 0;}Build against the installed library and run the saved program. An operation error produces a failing exit status:
Terminal window $ cmake -S . -B build -G Ninja \-DCMAKE_PREFIX_PATH="$PWD/libtmux-prefix" \-DCMAKE_CXX_COMPILER=clang++ \-DCMAKE_CXX_FLAGS=-stdlib=libc++ && \cmake --build build --parallel 2 && \./build/api_exampleExpected output:
sessions=1 windows=1 panes=1 clients=0
tmux command#
The tmux commands behind windows.
list-windows -a server scope, cmd_list_windows_exec tmux C API#
The C declarations in tmux that implement these commands.
In other ports#
List the server's windows
| Language | Equivalent |
|---|---|
| Python | libtmux |
| Ruby | Lib |
| Lua | libtmux |
| PowerShell | Lib Use the -Server parameter set to acquire window placements across all sessions. |
| Julia | Lib windows with a Snapshot reads every captured physical window. Use windowlinks for session placements. |
| Erlang | tmux Returns unique captured physical windows. window_links/1 lists session memberships. |
| Elixir | Lib Returns a Selection of every captured physical window. window_links/1 lists session placements. |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| Common Lisp | libtmux: windows on a snapshot returns captured physical windows once each. |
| TypeScript | server |
| Rust | server |
| Go | tmux |
| Java | io |
| Clojure | libtmux Acquires a new graph and returns its window placements without deduplicating linked windows. |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| F# | Lib Builds a deferred query for placements across all sessions. Query.list acquires the results; a linked window appears once for each session placement. |
| Swift | Server |
| OCaml | Libtmux Reads captured global windows; use window_links for indexed session placements. |
| Perl | Lib One entry per physical identity. window_links retains all session placements. |