How to send a command to all panes in tmux?

后端 未结 8 1008
夕颜
夕颜 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 <command> or tmux skap <command to send <command> to all panes.

    Note that tmux is aliased to my wrapper function tmux_pp.

    0 讨论(0)
  • 2021-01-29 18:09
    tmux send-keys -t <session id> <command> C-m  
    

    Replace the "session id" and "command" accordingly.

    0 讨论(0)
提交回复
热议问题