libtmux Reference MCP Search
On this page

server.settings.Server.array_option

View as Markdown

Module
server.settings
Declared in
Server
Package
libtmux
Source
crates/libtmux/src/server/settings.rs
array_option ( self , name : &str ) Result<SparseValues<TmuxText>, Error>
method [source]
method [source]
array_option

Read every value an array option holds, by index.

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?;

0 declared, 0 inherited

Esc

Type to search.