Create the eshell-command-alert helper

This commit is contained in:
Gergely Polonkai 2025-03-31 12:59:42 +02:00
parent bf4d26c1e3
commit ae016f9db4
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4

View File

@ -1030,6 +1030,20 @@ Function to bind it locally to =C-d=.
(local-set-key (kbd "C-d") #'eshell-C-d))
#+end_src
This sends an alert when an eshell command is finished. Taken from
[[https://blog.hoetzel.info/post/eshell-notifications/][here]].
#+begin_src emacs-lisp
(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))))
#+end_src
Now set up eshell.
#+begin_src emacs-lisp