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.array_option

Read every value an array option holds, by index.

Source and package
Qualified name
libtmux::server::Server::array_option
Module
server
Declared in
Server
Package
libtmux
Source
crates/libtmux/src/server/settings.rs
pub async fn array_option(&self, name: &str) -> Result< SparseValues<TmuxText>, Error >

Description#

Some tmux options hold a numbered set rather than one value: command-alias and terminal-overrides are the common ones, and every hook is one too. The indices are sparse and tmux keeps the gaps, so this reports them rather than a list. An empty result means the option holds nothing.

Errors

Returns an error when tmux does not recognize the option name.

Examples#

let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();
// Written far apart on purpose: nothing renumbers, so the gap stays.
server.set_array_option("command-alias", 30, "thirty=display -p 30").await?;
server.set_array_option("command-alias", 35, "five=display -p 35").await?;
let aliases = server.array_option("command-alias").await?;
assert_eq!(aliases.get(31), None, "the gap is tmux's, and it is kept");
assert_eq!(
aliases.get(35).map(|value| value.to_string_lossy().into_owned()),
Some("five=display -p 35".to_owned()),
);
server.unset_array_option("command-alias", 35).await?;
assert_eq!(server.array_option("command-alias").await?.get(35), None);
guard.shutdown().await?;
Parameters
Esc

Type to search.

Reference previewOpen reference