# server.Server.cmd

- **Module:** server
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/46cccfef2a546de55ce8b308249b8c76339089a0/packages/libtmux/src/server.ts#L1348
- **Page:** https://libtmux.org/en/ts/latest/reference/server-server-cmd/

```
cmd(
  command: string,
  args: readonly string[] = [],
  options?: CmdOptions,
): Promise<readonly string[]>
```

Run a tmux command this package does not model.

tmux has many more commands than any wrapper types. Rather than leaving a
caller to build their own subprocess — and reproduce the socket, the
environment, the deadline, and the error handling — this runs one through
the same path every other operation uses.

Failure raises [`TmuxCommandError`](/en/ts/latest/reference/errors-tmuxcommanderror/) like any other command, carrying
tmux's own stderr.

## Examples

```ts
await server.cmd("list-keys", ["-T", "copy-mode"]);
```

## Parameters

- `command` (`string`)
- `args` (`readonly string[]`)
  Default: `[]`.
- `options?` (`CmdOptions`)

## Guides

Pages that discuss `cmd`.

- [Filtering and queries](/en/ts/latest/concepts/queries/)

## In other ports

Run a tmux command this port does not model

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Server.cmd`](/en/py/latest/reference/libtmux-server-cmd/) (method) |
| Ruby | [`LibTmux::Server#run`](/en/ruby/latest/reference/libtmux-server-run/) (method) |
| Lua | [`libtmux.Server:command`](/en/lua/latest/reference/libtmux-server-command/) (method) |
| Elixir | [`LibTmux.Server.run/3`](/en/elixir/latest/reference/libtmux-server-run-3/) (function). Runs one trusted `Command` without attaching a client and returns bounded output with exit evidence. |
| Rust | [`server.Server.cmd`](/en/rs/latest/reference/server-server-cmd/) (method) |
| Go | [`tmux.Server.Cmd`](/en/go/latest/reference/tmux-server-cmd/) (method) |
| Java | [`io.github.libtmux.Server.cmd`](/en/java/latest/reference/io-github-libtmux-server-server-cmd/) (method) |
| C# | no equivalent on `Server` |
| C++ | no equivalent on `Server` |
| Swift | no equivalent on `Server` |

No equivalent is recorded in PowerShell, Julia, Kotlin, Scala or F#.
