Pane.send_keys
$ tmux send-keys to the pane.
Source and package
-
Description#
A leading space character is added to cmd to avoid polluting the user's history.
When
cmdis omitted (None), the wrapper emits a flag-only invocation — useful withreset=Trueorrepeat=Nto invoke tmux's deliberatecount == 0branch incmd-send-keys.cthat runs the flag effect without sending any keys. In flag-only mode,enteris forcedFalse(no keys → no Enter).Examples#
>>> pane = window.split(shell='sh')>>> pane.capture_pane()['$']>>> pane.send_keys('echo "Hello world"', enter=True)>>> pane.capture_pane()['$ echo "Hello world"', 'Hello world', '$']>>> print('\n'.join(pane.capture_pane())) # doctest: +NORMALIZE_WHITESPACE$ echo "Hello world"Hello world$Flag-only invocation — reset terminal state without sending any keys:
>>> pane.send_keys(reset=True)- Parameters
-
-
cmd(str | None) # – Text or input into pane.Nonefor flag-only invocation (requiresreset,repeat, orcopy_mode_cmdto be set). Now optional.Nonetriggers tmux's flag-only path. Versionchanged: 0.57 -
enter(bool | None) # – Send enter after sending the input, default True. -
suppress_history(bool | None) # – Prepend a space to command to suppress shell history, default False. Default changed from True to False. Versionchanged: 0.14 -
literal(bool | None) # – Send keys literally, default False. -
reset(bool | None) # – Reset terminal state before sending keys (-Rflag). added 0.56 -
copy_mode_cmd(str | None) # – Send a command to copy mode instead of keys (-Xflag). When set, cmd is ignored. added 0.56 -
repeat(int | None) # – Repeat count for the key (-Nflag). added 0.56 -
expand_formats(bool | None) # – Expand tmux format strings in keys (-Fflag). added 0.56 -
hex_keys(bool | None) # – Send keys as hex values (-Hflag). added 0.56 -
target_client(str | None) # – Specify a target client (-cflag). Requires tmux 3.4+. added 0.56 -
key_name(bool | None) # – Handle keys as key names (-Kflag). Requires tmux 3.4+. added 0.56
-
- Raises
-
-
Value
Error – IfcmdisNoneand no flag-only path is selected (reset,repeat, orcopy_mode_cmd).
-
tmux command
send-keysDiscussed in Sending keys · Pane interaction
In other ports Send keystrokes to a pane
- PowerShell No source-verified PowerShell equivalent is recorded for this operation.
- Julia No source-verified Julia equivalent is recorded for this operation.
- Ruby
- Lua
- TypeScript
- Rust
- Go
- Java no direct equivalent;
Pane.pastewrites a buffer instead - C#
- C++
- Swift
- Kotlin
- Scala
- F# No source-verified F# equivalent is recorded for this operation.