如何向 tmux 中的所有窗格发送命令?

问题描述:

我喜欢在具有巨大回滚的窗格上调用 :clear-history.但是,我想编写一种方法来将此命令发送到各个窗口中的所有窗格.

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.

我知道如何向所有窗口发送命令,这是由 提供的问题,但我如何向哪个窗口的所有窗格发送命令?

I know how to send a command to all the windows, courtesy of this question, but how do I send a command to all the panes of which window as well?

send-keyssynchronize-panes,但我不确定如何将它们结合在一起.但也许有一种更简单的方法可以做到这一点.

send-keys and synchronize-panes from the tmux manpage come to mind, but I'm not sure how to marry them together. But maybe there is a simpler way to do this.

稍微思考一下,tmux list-panes -a 似乎列出了当前会话中的所有窗格.开始时非常有用.我从这里去哪里?

Thinking about this a little bit, tmux list-panes -a seems to list all the panes in the current session. Pretty useful to start off with. Where do I go from here?

您是否尝试过在 tmux 窗口中跟随多个窗格

Have you tried following in tmux window with multiple panes

Ctrl-B :

setw synchronize-panes on

clear history