tmux发送到某个会话指定命令/按键

发送指定按键到tmux的特定会话:

1
tmux send-keys [-t <session-name>] <key>

key的取值参考tmux man手册

When specifying keys, most represent themselves (for example 'A' to 'Z'). Ctrl keys may be prefixed with 'C-' or '^', and Alt (meta) with 'M-'. In addition, the following special key names are accepted: Up, Down, Left, Right, BSpace, BTab, DC (Delete), End, Enter, Escape, F1 to F20, Home, IC (Insert), NPage (Page Up), PPage (Page Down), Space, and Tab. Note that to bind the '"' or ''' keys, quotation marks are necessary

例如,向会话mc发送指令ls并按回车执行

1
tmux send-keys -t mc ls Enter

向会话mc发送bash start.sh并按回车执行

1
tmux send-keys -t mc bash Space start.sh Enter


tmux发送到某个会话指定命令/按键
https://jcdu.top/2022/07/13/tmux发送到某个会话指定命令_按键/
作者
horizon86
发布于
2022年7月13日
许可协议