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

Python API

Python documentation

libtmux.Session.cmd

Python

View as Markdown

Module
libtmux
Declared in
Session
Package
libtmux
Source
src/libtmux/session.py
Other languages
Ruby Lua TypeScriptRustGo Java .NET C++ Swift
cmd ( self , cmd : str , args : t.Any , target : str | int | None = None ) → tmux_cmd
method [source]
method [source]
cmd

Execute tmux subcommand within session context.

Automatically binds target by adding -t for object's session ID to the command. Pass target to keyword arguments to override.

Parameters
  • target ( str | int | None ) – Optional custom target override. By default, the target is the session ID.

Returns

server.cmd

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

>>> 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"]);
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.