Core LibrarystableAPI Reference

Choose documentation 3

stable

Current version

stable
English

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

Python API

method libtmux stable

Server.run_shell

Execute a shell command via $ tmux run-shell.

Source and package
Qualified name
libtmux.Server.run_shell
Module
libtmux
Declared in
Server
Package
libtmux
Source
src/libtmux/server.py
Other languages
PowerShell Julia Ruby Lua TypeScriptRustGoJavaC#C++ Swift Kotlin Scala F#
run_shell ( self, command: str, background: bool | None = None, delay: str | None = None, as_tmux_command: bool | None = None, target_pane: str | None = None, cwd: StrPath | None = None, show_stderr: bool | None = None, args: list[str] | None = None, ) → list[str] | None

Examples#

>>> result = server.run_shell('true')
>>> isinstance(result, list)
True
Parameters
  • command (str) # – Shell command to execute.

  • background (bool | None) # – Run in background (-b flag).

  • delay (str | None) # – Delay before execution (-d flag).

  • as_tmux_command (bool | None) # – Parse argument as a tmux command instead of a shell command (-C flag).

  • target_pane (str | None) # – Target pane for output (-t flag).

  • cwd (StrPath | None) # – Start directory for the shell command (-c flag). When omitted, tmux uses the target client's current working directory. Requires tmux 3.4+; on older tmux a warning is emitted and the kwarg is ignored. Note: tmux's -c is a start directory, not subprocess semantics. If chdir(cwd) fails, tmux falls back to the user's home directory, then to /, rather than raising — unlike Python's subprocess.Popen(cwd=) which errors on a failed chdir. added 0.57

  • show_stderr (bool | None) # – Combine the command's stderr into the captured output stream (-E flag, maps to JOB_SHOWSTDERR). Requires tmux 3.6+; on older tmux a warning is emitted and the kwarg is ignored. added 0.57

  • args (list[str] | None) # – Positional arguments passed after command, expanded as #{1}, #{2}, … inside it. Requires tmux 3.7+; warns and is ignored on older tmux.

Returns

list[str] | None Stdout lines, or None when background is True. Empty list on tmux 3.3a/3.4 (upstream stdout passthrough was broken until 3.5).

tmux command run-shell

In other ports Run a shell command through tmux
Esc

Type to search.

Reference preview Open reference