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

session.Session.cmd

TypeScript

View as Markdown

Module
session
Declared in
Session
Package
libtmux
Source
packages/libtmux/src/session.ts
Other languages
Python Ruby Lua RustGo Java .NET C++ Swift
cmd ( command : : string , args : : readonly string[] = [] , options : : CmdOptions ) → Promise<readonly string[]>
method [source]
method [source]
cmd

Run a tmux command this package does not model, addressed at this session.

The first argument is the tmux command name and nothing else — this does not parse a command line, so arguments go in the array:

The session's id is sent as the target; pass target to address something else, or null for a command that takes none.

In other ports Run a tmux command addressed at a session
  • Python libtmux.Session.cmd
  • Ruby No source-verified Ruby equivalent is recorded for this operation.
  • Lua No source-verified Lua equivalent is recorded for this operation.
  • Rust 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

Examples

await session.cmd("rename-session", ["--", "renamed"]);
>>> 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_...))
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?;

0 declared, 0 inherited

Esc

Type to search.