tmux 有send-keys
一个非常有用的命令。这个命令的一个特性是它“按你的意思做”,比如允许你ENTER
使用发送tmux send-keys
。这或许是个不错的 hack,但它让我在编程中使用时感到紧张。
有没有办法指定以“原始”模式发送键,以便“ENTER”不会转换为换行符?
我看了一下手册,没有看到选项:
send-keys [-FHKlMRX] [-c target-client] [-N repeat-count] [-t target-pane] key ...
(alias: send)
Send a key or keys to a window or client. Each argument key is the name of the key
(such as ‘C-a’ or ‘NPage’) to send; if the string is not recognised as a key, it is sent
as a series of characters. If -K is given, keys are sent to target-client, so they are
looked up in the client's key table, rather than to target-pane. All arguments are sent
sequentially from first to last. If no keys are given and the command is bound to a
key, then that key is used.
The -l flag disables key name lookup and processes the keys as literal UTF-8 characters.
The -H flag expects each key to be a hexadecimal number for an ASCII character.
The -R flag causes the terminal state to be reset.
-M passes through a mouse event (only valid if bound to a mouse key binding, see “MOUSE
SUPPORT”).
-X is used to send a command into copy mode - see the “WINDOWS AND PANES” section. -N
specifies a repeat count and -F expands formats in arguments where appropriate.
一种解决方法是将每个字符作为单独的参数发送,以便通过编程使用。我使用了tmuxp Python 库,它很可能解决了这个问题,同时提供了完整的 API。但我想在 Shell 中执行此操作。