当我重新启动 Emacs 时,我经常(每周)做这种事情:
- 打开连接到 RSH 服务器的 shell,执行一些命令,重命名缓冲区
- 对几台不同的远程机器重复步骤 1
我在想:有没有办法让我可以在启动脚本中对这些设置进行硬编码?
最佳答案
这是一个启动 shell、ssh-es 到主机并在进入交互式 shell 之前运行命令的函数:
(defun start-remote-shell (host command)
(shell (format "*shell-%s*" host))
(sleep-for 0 500) ; Wait half a second for the prompt to appear
(insert (format "ssh -t %s %s'; exec bash -i'"
(shell-quote-argument host)
(shell-quote-argument (shell-quote-argument command))))
(comint-send-input))
您可以将此片段放入您的.emacs
文件中,然后是您想要的特定调用,例如:
(start-remote-shell "server-one" "apache start")
(start-remote-shell "server-two" "mysql start")
(start-remote-shell "server-three" "foo start")
关于emacs - 设置 emacs shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11605478/