libtmux.Server.run_shell
- Module
- libtmux
- Declared in
- Server
- Package
- libtmux
- Source
- src/libtmux/server.py
- Other languages
- Ruby Lua TypeScriptRustGoJava.NETC++ Swift
-
Execute a shell command via
$ tmux run-shell.- Parameters
-
-
command ( str ) – Shell command to execute.
-
as_tmux_command ( bool | None ) – Parse argument as a tmux command instead of a shell command (
-Cflag). -
target_pane ( str | None ) – Target pane for output (
-tflag). -
cwd ( StrPath | None ) – Start directory for the shell command (
-cflag). 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-cis a *start directory*, not subprocess semantics. Ifchdir(cwd)fails, tmux falls back to the user's home directory, then to/, rather than raising — unlike Python'ssubprocess.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 (
-Eflag, maps toJOB_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).
In other ports Run a shell command through tmux
- Ruby
LibTmux::Server#run - Lua No source-verified Lua equivalent is recorded for this operation.
- TypeScript
server.Server.runShell - Rust
server.Server.run_shell - Go
tmux.Server.RunShell - Java
io.github.libtmux.Server.Server.runShell - .NET
LibTmux.Server.RunShellAsync - C++
libtmux::Server::run_shell - Swift
Server.run(_:in:)types a command into a pane rather than running it on the host
Examples
>>> result = server.run_shell('true')>>> isinstance(result, list)Trueconst lines = await server.runShell("echo hello");lines[0]; // "hello"0 declared, 0 inherited