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.

struct libtmux-rs latest

KeyBinding

One key binding, as tmux holds it.

Source and package
Qualified name
libtmux::server::keys::KeyBinding
Module
server.keys
Package
libtmux
Source
crates/libtmux/src/server/keys.rs
struct server.keys.KeyBinding

Description#

bind-key -n is -T root, so Self::table() answers it. The command is the text a bind-key line in a configuration file carries, with \; between commands, and is not parsed further. That is argument syntax: as the single command string Server::bind_key() takes, \; is a literal semicolon rather than a separator.

Examples#

let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();
server.bind_key("prefix", "Y", "display-message hello").await?;
let version = server.capabilities().await?.tmux_version().clone();
if version.has_behavior(&libtmux::since::LIST_KEYS_FORMAT) {
let bindings = server.typed_key_bindings(Some("prefix")).await?;
let bound = bindings
.iter()
.find(|binding| binding.key() == "Y")
.ok_or("the binding is listed")?;
assert_eq!(bound.command(), "display-message hello");
assert!(!bound.repeats());
assert_eq!(bound.note(), None);
}
guard.shutdown().await?;

Members5#

  • command method Return the bound command list, as a bind-key line renders it.
  • key method Return the key as tmux names it, such as C-b or ", unquoted.
  • note method Return the note bind-key -N attached, if any.
  • repeats method Report whether the binding repeats, bind-key -r.
  • table method Return the key table, such as prefix, root or copy-mode-vi.
Esc

Type to search.

Reference previewOpen reference