Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

capture_pane

Read a pane’s contents. Reads the visible screen by default; set history to reach output that has scrolled off, or give a start and end line. Set last_command to get only what the last command printed, which is usually what you want and is far shorter — it needs tmux 3.7 and a shell that marks its prompts, and says so when it cannot. Read pane output; accepts no client-supplied executable input. Returned content may be sensitive or untrusted.

All Rust tools · JSON · Source

Arguments

end optional · integer | null
End at this line. Omit for the bottom of the screen.
history optional · boolean
Read the whole history rather than the visible screen.

Default: false.

last_command optional · boolean
Return only the last command's output, when the shell marks its prompts. Answers far less than the history, because it starts where the last command's output began. When the pane's shell does not mark its prompts -- fish does, bash and zsh do not -- this reports `marks: "absent"` and returns the visible screen instead.

Default: false.

pane required · string
The `%`-prefixed pane id.
start optional · integer | null
Start at this line. Zero is the top of the screen, negative is scrollback. Omit for the top of the screen, or of the scrollback with `history`.

Schemas

The schema defines required fields, nested values, defaults, and validation constraints.

Input schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"end": {
"description": "End at this line. Omit for the bottom of the screen.",
"format": "int32",
"type": [
"integer",
"null"
]
},
"history": {
"default": false,
"description": "Read the whole history rather than the visible screen.",
"type": "boolean"
},
"last_command": {
"default": false,
"description": "Return only the last command's output, when the shell marks its\nprompts.\n\nAnswers far less than the history, because it starts where the last\ncommand's output began. When the pane's shell does not mark its\nprompts -- fish does, bash and zsh do not -- this reports\n`marks: \"absent\"` and returns the visible screen instead.",
"type": "boolean"
},
"pane": {
"description": "The `%`-prefixed pane id.",
"type": "string"
},
"start": {
"description": "Start at this line. Zero is the top of the screen, negative is\nscrollback. Omit for the top of the screen, or of the scrollback with\n`history`.",
"format": "int32",
"type": [
"integer",
"null"
]
}
},
"required": [
"pane"
],
"type": "object"
}
Output schema
{
"$defs": {
"Marks": {
"description": "Whether tmux knew where the last command's output began.\n\nReported rather than inferred: an answer that fell back to the whole\nscreen looks exactly like a command that printed a great deal.",
"oneOf": [
{
"const": "present",
"description": "The prompt marks were there, so the text is one command's output.",
"type": "string"
},
{
"const": "absent",
"description": "tmux has the marks but this pane has none, because its shell does not\nemit OSC 133. fish does; bash and zsh need shell integration. The\nvisible screen came back instead -- not the history, which would\nanswer a request for one command with everything the pane ever wrote.",
"type": "string"
},
{
"const": "unsupported",
"description": "This tmux predates `capture-pane -F`, which arrived in 3.7. The\nvisible screen came back instead.",
"type": "string"
},
{
"const": "not_asked",
"description": "The caller did not ask for the last command, so nothing was looked up.",
"type": "string"
}
]
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"lines": {
"description": "How many lines that is.",
"minimum": 0,
"type": "integer"
},
"marks": {
"$ref": "#/$defs/Marks",
"description": "Whether the text is one command's output, and why it is not."
},
"pane": {
"description": "The pane that was read.",
"type": "string"
},
"text": {
"description": "The text, with lines separated by newlines.",
"type": "string"
}
},
"required": [
"pane",
"text",
"lines",
"marks"
],
"type": "object"
}
Tool annotations
{
"destructiveHint": false,
"idempotentHint": true,
"openWorldHint": true,
"readOnlyHint": true,
"title": "Read Pane Contents"
}
Esc

Type to search.