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#
The tmux commands behind send_keys.
tmux C API#
The C declarations in tmux that implement these commands.
Guides#
Pages that discuss send_keys.
- Guides
- Topics
In other ports#
Send keystrokes to a pane
| Language | Equivalent |
|---|---|
| Ruby | Lib |
| Lua | libtmux |
| Erlang | tmux |
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| Common Lisp | libtmux: |
| TypeScript | pane |
| Rust | pane |
| Go | tmux |
| Java | no direct equivalent; Pane.paste writes a buffer instead |
| Clojure | libtmux |
| Kotlin | io |
| Scala | io |
| C# | Lib |
| C++ | libtmux:: |
| Swift | Server |
| OCaml | Libtmux |
| Perl | Lib Explicit Server operation. Captured entities remain local observations; use a new snapshot to observe changes. |
No equivalent is recorded in PowerShell, Julia, Elixir or F#.