# libtmux.Pane.cmd

- **Module:** libtmux
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/pane.py#L290
- **Page:** https://libtmux.org/en/py/stable/reference/libtmux-pane-cmd/

```
libtmux.Pane.cmd(
    self,
    cmd: str,
    args: t.Any,
    target: str | int | None = None,
) -> tmux_cmd
```

Execute tmux subcommand within pane context.

Automatically binds target by adding  ``-t`` for object's pane ID to the
command. Pass ``target`` to keyword arguments to override.

## Examples

```python
>>> pane.cmd('split-window', '-P').stdout[0]
'libtmux...:...'
```

From raw output to an enriched `Pane` object:

```python
>>> Pane.from_pane_id(pane_id=pane.cmd(
... 'split-window', '-P', '-F#{pane_id}').stdout[0], server=pane.server)
Pane(%... Window(@... ...:..., Session($1 libtmux_...)))
```

## Parameters

- `cmd` (`str`)
- `args` (`t.Any`)
- `target` (`str | int | None`): Optional custom target override. By default, the target is the pane ID.

## Returns

:meth:`server.cmd`

## In other ports

### Run a tmux command addressed at a pane

- TypeScript: [`pane.Pane.cmd`](/en/ts/latest/reference/pane-pane-cmd/) (method)
- Rust: [`pane.Pane.cmd`](/en/rs/latest/reference/pane-pane-cmd/) (method)
- Go: [`tmux.Pane.Cmd`](/en/go/latest/reference/tmux-pane-cmd/) (method)
