libtmux Reference MCP Search
On this page

libtmux.Server.run_shell

View as Markdown

Module
libtmux
Declared in
Server
Package
libtmux
Source
src/libtmux/server.py
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
method [source]
method [source]
run_shell

Execute a shell command via $ tmux run-shell.

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).

0 declared, 0 inherited

Esc

Type to search.