Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux-rs latest

Server.chain

Dispatch several commands as one tmux a \; b invocation.

Source and package
Qualified name
libtmux::server::Server::chain
Module
server
Declared in
Server
Package
libtmux
Source
crates/libtmux/src/server.rs
Other languages
Perl Erlang PowerShell Julia Elixir Haskell Common Lisp Python Ruby Lua TypeScript Go JavaC#C++ Swift Kotlin Scala OCaml F# Clojure
pub async fn chain(&self, chain: CommandChain) -> Result< CommandResult, Error >

Description#

One process, one exit status, one merged stdout. tmux runs the chain up to the first failure and drops the remainder, so this trades the ability to tell which command failed for a single round trip. The merged result is identical whichever member failed: use it when the commands succeed or fail as a unit, and Server::cmd() when you need to know where a failure happened.

Errors

Returns an error when the process cannot be started, captured, awaited, or is cancelled by timeout or shutdown. A command tmux refuses is reported through the returned CommandResult, not as an error.

Examples#

use libtmux::{Command, CommandChain};
let server = libtmux::Server::builder()
.socket_path("/tmp/libtmux-rs-test/chain-example-absent.sock")
.build()?;
let chain = CommandChain::new(Command::new("list-sessions"))
.then(Command::new("list-panes"));
let result = server.chain(chain).await?;
assert!(result.exit_code().is_some());
server.shutdown().await?;
Parameters

Guides#

Pages that discuss chain.

In other ports#

Run several commands in one tmux invocation

Equivalents of Run several commands in one tmux invocation in other languages
Language Equivalent
Python no equivalent on Server
Haskell No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
TypeScript no equivalent on Server
Go no equivalent on Server
Java io.github.libtmux.Server.chain
C# LibTmux.Server.Chain
C++ libtmux::Server::run_chain
Swift no equivalent on Server
OCaml No direct public OCaml equivalent is recorded for this operation.
Perl batch executes ordered independent requests, not a tmux command list in one invocation; command chaining is deferred.

No equivalent is recorded in Ruby, Lua, PowerShell, Julia, Erlang, Elixir, Common Lisp, Clojure, Kotlin, Scala or F#.

Esc

Type to search.

Reference previewOpen reference