How to send a command to all panes in tmux?

后端 未结 8 1006
夕颜
夕颜 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:09

    A bit late to the party but I didn't want to set and unset synchronize-panes just to send one command so I created a wrapper function around tmux and added a custom function called send-keys-all-panes.

    _tmux_send_keys_all_panes_ () {
      for _pane in $(tmux list-panes -F '#P'); do
        tmux send-keys -t ${_pane} "$@"
      done
    }
    

    I also create a wrapper around the tmux command to simplify calling this function (for convenience). The wrapper and the above code are all here.

    This allows me to run tmux send-keys-all-panes or tmux skap to send to all panes.

    Note that tmux is aliased to my wrapper function tmux_pp.

提交回复
热议问题