Server.run_shell
Execute a shell command via $ tmux run-shell.
Source and package
-
Examples#
>>> result = server.run_shell('true')>>> isinstance(result, list)True- Parameters
-
-
background(bool | None) # – Run in background (-bflag). -
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).
tmux command#
The tmux commands behind run_shell.
tmux C API#
The C declarations in tmux that implement these commands.
In other ports#
Run a shell command through tmux
| Language | Equivalent |
|---|---|
| Ruby | Lib |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | server |
| Rust | server |
| Go | tmux |
| Java | io |
| C# | Lib |
| C++ | libtmux:: |
| Swift | Server.run(_:in:) types a command into a pane rather than running it on the host |
| OCaml | No direct public OCaml equivalent is recorded for this operation. |
| Perl | No dedicated equivalent in the selected Perl surface. Explicit Server::cmd remains available for native tmux commands. |
No equivalent is recorded in Lua, PowerShell, Julia, Erlang, Elixir, Common Lisp, Clojure, Kotlin, Scala or F#.