With minimal testing, this will do:
(defun send-to-all-shells () (interactive) (let ((command (read-from-minibuffer "Command: "))) (mapcar #'(lambda (x) (comint-send-string x (concat "\n" command "\n"))) (remove-if-not #'(lambda (x) (string= "/bin/bash" (car (process-command x)))) (process-list)))))
To start, just Mx send-to-all-shells , enter the desired command and it will be sent to all open shells. This assumes your shell is in /bin/bash . If not, change this bit accordingly.
If you do this a lot, you will want to associate it with your favorite key combo. It would be possible to borrow and modify the code in comint-send-input , so that you can simply enter the desired command on the command line of one shell, press your key and send this command to all the commands at the same time. I am short on time, so I will leave this as an exercise for the reader.
Tyler source share