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

Session.set_typed_option

Set one option to a typed value, checked before it is sent.

Source and package
Qualified name
libtmux::session::Session::set_typed_option
Module
session
Declared in
Session
Package
libtmux
Source
crates/libtmux/src/session/settings.rs
pub async fn set_typed_option( &self, name: &str, value: impl Into<OptionValue>, ) -> Result<(), Error>

Description#

The value must be the variant Self::typed_option() reads back for the option: true for mouse, a number for history-limit, and "vi" for the choice status-keys. OptionValue gives the rules, and the two writes it cannot check. The value is marked sensitive, as in Self::set_option().

Errors

Returns crate::Error::OptionValueRefused without sending anything when tmux's option table refuses the value: the wrong variant, a word outside a choice's set, or a number outside its range.

Returns crate::Error::OptionScopeMismatch when tmux keeps the option in another of its tables, and an error when tmux rejects the name or value.

Examples#

use libtmux::{Error, OptionValue};
let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("typed").await?;
session.set_typed_option("history-limit", 5000).await?;
assert_eq!(
session.typed_option("history-limit").await?,
Some(OptionValue::Number(5000)),
);
// Below the range tmux's table declares, so it is never sent.
let refused = session.set_typed_option("history-limit", -1).await;
assert!(matches!(refused, Err(Error::OptionValueRefused { .. })));
guard.shutdown().await?;
Parameters

tmux command#

The tmux commands behind set_typed_option.

tmux C API#

The C declarations in tmux that implement these commands.

Esc

Type to search.

Reference previewOpen reference