Server.RunShell
RunShell executes a shell command through tmux and returns an owned stdout slice. Captured foreground shell jobs require tmux 3.5 before execution; older releases deliver that output to no client. A background request returns nil after tmux accepts the job. TargetPane delivers output to that pane on older supported daemons. AsTmuxCommand uses native tmux command semantics rather than promising captured shell-job output. Unsupported optional flags follow UnsupportedPolicy. A completed stderr result is an error; context cancellation can be observed with errors.Is but does not establish that tmux did not start the job.
Source and package
- Qualified name
-
tmux.Server. Run Shell - Package
- tmux
- Declared in
Server- Distribution
- github.com/libtmux/libtmux-go/tmux
- Source
- tmux/server_exec.go
- Other languages
- Perl Erlang PowerShell Julia Elixir Haskell Common Lisp PythonRuby Lua TypeScriptRustJavaC#C++ Swift Kotlin Scala OCaml F# Clojure
- func (s Server) RunShell( ctx context
.Context , request RunShell , ) ([]string, error)Request -
Description#
On a
Connection-bound server a foreground request runs on a control client opened for that call and closed when it ends, asServer.WaitFordoes, so a slow or canceled command leaves every lane free. tmux sends that client the command's output as lines outside any reply frame, so the client takes every line before its own fence as output, whatever the line looks like. The one exception is a line that is a well-formed control notification, such as "%window-add @1", which a connection cannot tell from tmux's own and drops.A foreground command that tmux ends with success is checked against the server, as in
Server.WaitFor, and returns an error matchingErrNoServerwhen the server exited under it.- Parameters
tmux command#
The tmux commands behind RunShell.
tmux C API#
The C declarations in tmux that implement these commands.
In other ports#
Run a shell command through tmux
| Language | Equivalent |
|---|---|
| Python | libtmux |
| Ruby | Lib |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | server |
| Rust | server |
| 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#.