# libtmux.Pane.cmd

- **Module:** libtmux.Pane
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/pane.py#L309
- **Page:** https://libtmux.org/reference/py/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.

## Parameters

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

## Example

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

## Example

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