How to send a command to all panes in tmux?

后端 未结 8 1011
夕颜
夕颜 2021-01-29 17:13

I like to call :clear-history on panes with a huge scrollback. However, I want to script a way to send this command to all the panes in the various windows.

8条回答
  •  礼貌的吻别
    2021-01-29 18:00

    You can combine synchronize-panes and send-keys in a single shortcut to send commands to all the panes:

    Predefined tmux command clear-history:

    bind-key C set-option -w synchronize-panes on\; clear-history \; set-option -w synchronize-panes off
    

    Prompt an arbitrary tmux command:

    bind-key p command-prompt -p "Panes command: " "set-option -w synchronize-panes on; %% ; set-option -w -u synchronize-panes"
    

    Prompt an arbitrary shell command:

    bind-key p command-prompt -p "Panes command: " "set-option -w synchronize-panes on; send-keys %%\\n ; set-option -w -u synchronize-panes"
    

提交回复
热议问题