session.Session.cmd
Rust
- Python
- TypeScript
- Rust
- Go
- Java Unavailable
- .NET Unavailable
- C++ Unavailable
- Swift Unavailable
- Module
- session
- Declared in
- Session
- Package
- libtmux
- Source
- crates/libtmux/src/session.rs
- Other languages
- PythonTypeScriptGo Java .NET C++ Swift
-
Run a raw tmux command against this session.
The escape hatch for anything this crate does not wrap.
-tis 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
CommandResultrather than as an error, the same ascrate::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 session
- Python
libtmux.Session.cmd - TypeScript
session.Session.cmd - Go
tmux.Session.Cmd - Java no equivalent on
Session - .NET no equivalent on
Session - C++ no equivalent on
Session - Swift no equivalent on
Session
- Python
Examples
let guard = libtmux::test::TestServer::new().await?;let session = guard.server().new_session("raw").await?;
let result = session .cmd(libtmux::Command::new("display-message").arg("-p").arg("#{session_name}")) .await?;assert_eq!(result.stdout_lossy().trim(), "raw");
guard.shutdown().await?;>>> session.cmd('new-window', '-P').stdout[0]'libtmux...:....0' From raw output to an enriched Window object:
>>> Window.from_window_id(window_id=session.cmd(... 'new-window', '-P', '-F#{window_id}').stdout[0], server=session.server)Window(@... ...:..., Session($1 libtmux_...))await session.cmd("rename-session", ["--", "renamed"]);0 declared, 0 inherited