I always use Eshell to interact with the operating system because it seamlessly integrates with Emacs, support processing (remote) TRAMP file, but also on Windows can work very well.
After starting the shell command (such as time-consuming task of building serious) I often forget to run due to the switching buffer status tracking task.
Thanks to the Emacs hook mechanism, you can configure Emacs elisp call a function after the completion of an external command.
I use John Wiegleys awesome written alert package to send desktop notifications:
(require 'alert)
(defun eshell-command-alert (process status)
"Send `alert' with severity based on STATUS when PROCESS finished."
(let* ((cmd (process-command process))
(buffer (process-buffer process))
(msg (format "%s: %s" (mapconcat 'identity cmd " ") status)))
(if (string-prefix-p "finished" status)
(alert msg :buffer buffer :severity 'normal)
(alert msg :buffer buffer :severity 'urgent))))
(add-hook 'eshell-kill-hook #'eshell-command-alert)
alert rules can be set by the program. For me this situation, when I just need to be notified when the corresponding buffer is not visible:
(alert-add-rule :status '(buried) ;only send alert when buffer not visible
:mode 'eshell-mode
:style 'notifications)
This even for TRAMP also become effective. The following screenshot shows the failure of the make
Gnome desktop notifications generated command.
via: https://blog.hoetzel.info/post/eshell-notifications/
Author: Jürgen Hötzel topics: lujun9972 Translator: lujun9972 proofread: wxy
This article from the LCTT original compiler, Linux China is proud