View on GitHub


A multi-casting script for Tmux

Download this project as a .zip file Download this project as a tar.gz file


A simple tmux multicast program for sending commands to multiple panes at once. Tmux is a terminal multiplexer and is a powerful means to reach beyond what the standard terminal emulator can achieve by allowing a hierarchy of sessions, windows, and panes, including the means to dynamically split windows using simple hotkey combinations. There is already means to send messages and commands to other panes, by use of the tmux send-keys command. Utilizing shell loops it is more than possible to use the same mechanism to broadcast to all panes, and with the inclusion of conditionals it can be mutated into multicast.

So the question of why a script may be required arises, that is because having used these features, I have found them difficult to implement on the fly, overly verbose and undescriptive, and haphazard at best. So I concluded a simple script program that can be told which panes to send to could ease many of these problems and yield a much faster and more effective result, making tmux significantly more powerful. Why such an unusually specific feature? I am a DevOps Engineer, as such I regularly find new ways to automate old methods, all as a means to manage increasingly large arrays of machines and provide products en masse to clients through seamless integration. Despite the multitude of powerful tools already at my disposal, and the incredible ubiquity of software like Ansible, it does not quite negate the need for manually performing the same task by logging into many machines at once, so enabling this to be done simply and decisively by tmux would be a huge boon to overall efficiency and consistency.

Regardless of all that though, there are probably many reasons such a tool would be useful, demonstration of clustering software would be a good example, but I’m sure you have some of your own. So why not apply to add such a feature to tmux itself? Perhaps in the future I will, until then I have a number of thresholds to overcome. Firstly I am not of software developer quality, at least not yet, so I could not reliably provide the code they would need to make such a feature work. Secondly this presents an excellent learning opportunity for development on open source tools in general, which is in part why I chose to do it in C. Finally even assuming all the steps up to providing a pull request to their repository are met, there is still the issue of need, if there is not need enough, there will be no point to them implementing it, tackling it this way allows us to see how much need there is, and if there is a lot, they may notice and implement the feature themselves rendering this repo obsolete. Either way there’s only one way to find out!