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

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

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并按回车执行

tmux send-keys -t mc ls Enter

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

tmux send-keys -t mc bash Space start.sh Enter
posted @ 2022-07-13 13:30  王冰冰  阅读(627)  评论(0编辑  收藏  举报