Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

window.Window.cmd

Rust

View as Markdown

Module
window
Declared in
Window
Package
libtmux
Source
crates/libtmux/src/window.rs
Other languages
Python Ruby Lua TypeScriptGo Java .NET C++ Swift
cmd ( self , command : Command ) → Result<CommandResult, Error>
method [source]
method [source]
cmd

Run a raw tmux command against this window.

The escape hatch for anything this crate does not wrap. -t is placed after the subcommand for you, because tmux stops reading flags at the first positional: a target appended after one is taken as text, and the command then succeeds having acted on something else.

A non-zero exit status comes back in the CommandResult rather than as an error, the same as crate::Server::cmd .

Errors

Returns an error when the process cannot be started, captured, or awaited.

In other ports Run a tmux command addressed at a window
  • Python libtmux.Window.cmd
  • Ruby No source-verified Ruby equivalent is recorded for this operation.
  • Lua No source-verified Lua equivalent is recorded for this operation.
  • TypeScript window.Window.cmd
  • Go tmux.Window.Cmd
  • Java no equivalent on Window
  • .NET no equivalent on Window
  • C++ no equivalent on Window
  • Swift no equivalent on Window

Examples

let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("raw").await?;
let window = session.active_window().await?.expect("a window");
let result = window
.cmd(libtmux::Command::new("display-message").arg("-p").arg("#{window_id}"))
.await?;
assert_eq!(result.stdout_lossy().trim(), window.id().to_string());
guard.shutdown().await?;

Create a pane from a window:

>>> window.cmd('split-window', '-P', '-F#{pane_id}').stdout[0]
'%...'

Magic, directly to a Pane :

>>> Pane.from_pane_id(pane_id=session.cmd(
... 'split-window', '-P', '-F#{pane_id}').stdout[0], server=session.server)
Pane(%... Window(@... ...:..., Session($1 libtmux_...)))
await window.cmd("rotate-window");

0 declared, 0 inherited

Esc

Type to search.