Is there something like multiple-cursors, but that would send input into multiple buffers at once?

Use case: I want to send the same shell commands to a number of virtual machines and see the output in the real time. Maybe multi-term can do this?

PS. Sorry for non-descriptive tags, feel free to add more.

  • 1
    This is an "outside emacs solution" but if you use tmux, it can have multiple panes split in a window. Each pane runs an independent shell env. You can then enable/disable synchronization across all panes (think of emacs windows) in a window (think of emacs frame) by setting the window variable synchronize-panes to on or off. Just like in emacs, you can set custom key bindings in tmux too. With sync enabled, you can then send the same command to each shell. Jan 7 '16 at 16:45
  • ansible? fabric? puppet?
    – Nsukami _
    Jan 7 '16 at 16:48
  • @kaushalmodi It's mostly because I envy people who use it :) the guy at the desk next to me can do it, but I can't, when using Emacs as my terminal. It just feels wrong to leave Emacs for something like that :)
    – wvxvw
    Jan 7 '16 at 19:43
  • @Nsukami_ imagine the amount of work needed to get this done by, say, a Puppet script? All of that just to ping a server from several VMs? That's sure an overkill.
    – wvxvw
    Jan 7 '16 at 19:45

If you have to stay in emacs, then the two options I've tried are:

(process-send-string "my-vm-1" "command to vm")

where I'd change my-vm-1 to my-vm-2 and so on in a macro. The other option I use now is to run gnu-parallel via M-x !.

A more recent solution for VMs to use their own mgmt interface to send commands to to multiple instances. This may turn out to be the most robust in the long-run especially if you rely on nagios-type remote management tools.


Would gnu-parallel be able to jump these multiple hops?

I don't see why not. At its most simplest, just invoke another gnu-parallel command on each remote VM. If you need to customize some portion of your command to each VM, look into gnu-parallel's --hostgroup option under sshlogin. This script might give you ideas on how to loop through them.

You realize all this is far from tweaking with emacs buffers but not all that different from Tramp's multi-hops. Maybe a custom external method in Tramp can hop into each container, run a custom command, and return the results as a log buffer back to emacs.

  • If you used gnu-parallel, would you tell if this scenario is plausible: I'm working on a data center with several VMs, each of which may have several Docker containers running. The way I connect to containers is by running docker -ti run <image> bash from an SSH session inside the VM (typically with more options affecting the way the container is run). I am not always able to connect directly from my computer to the container. Would gnu-parallel be able to jump these multiple hops? Would it send following commands in the same session?
    – wvxvw
    Jan 8 '16 at 7:36
  • see the addendum to my previous response
    – Emacs User
    Jan 8 '16 at 10:43
  • thanks, I'll give it a try when I'm in the office and will report back my findings. I'm not accepting the question yet since there may be interesting "pure" Emacs solutions. After all, it shouldn't be that difficult to make Emacs insert text in several buffers at once.
    – wvxvw
    Jan 9 '16 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.