emacs shell:输入一次,到处运行

Ish*_*eck 4 emacs ecl eshell terminal-emulator

在emacs中,我希望打开多个shell,输入一次命令,并让它在每个shell中运行 - 类似于multixterm(http://freecode.com/projects/multixterm)的方式.

Tyl*_*ler 7

通过一些最小的测试,这将做:

(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)))))
Run Code Online (Sandbox Code Playgroud)

要运行,只需M-x send-to-all-shells输入您想要的命令,它将被发送到所有打开的shell.假设你的shell被发现了/bin/bash.如果不是,请相应地更改该位.

如果你做了很多,你会想要将它绑定到你最喜欢的键组合.可以借用和修改代码,comint-send-input以便您可以在一个shell的提示符下输入所需的命令,点击您的密钥并将该命令同时发送到所有shell.我的时间很短,所以我会将其作为练习留给读者.