# libtmux.Server.run_shell

- **Module:** libtmux.Server
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/server.py#L506
- **Page:** https://libtmux.org/reference/py/libtmux-server-run_shell/

```
libtmux.Server.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
```

Execute a shell command via ``$ tmux run-shell``.

## Parameters

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

## Example

```python
>>> result = server.run_shell('true')
>>> isinstance(result, list)
True
```
