Make sure the Nyan prompt in eshell always works

This commit is contained in:
Gergely Polonkai 2018-08-28 18:12:52 +02:00
parent 84e1b7ab32
commit 6b7b2d67c6
2 changed files with 15 additions and 7 deletions

View File

@ -1314,9 +1314,7 @@ The cookies are from the Hungarian version an ancient MS-DOS based program calle
#+BEGIN_SRC emacs-lisp
(when (display-graphic-p)
(use-package nyan-prompt
:ensure nil
:config
(add-hook 'eshell-load-hook 'nyan-prompt-enable)))
:ensure nil))
#+END_SRC
*** Zone out with Nyancat
@ -1439,7 +1437,9 @@ Highlight point. Sometimes its not easy to see.
(with-eval-after-load "esh-opt"
(autoload 'epe-theme-lambda "eshell-prompt-extras")
(setq eshell-highlight-prompt nil
eshell-prompt-function 'epe-theme-lambda)))
eshell-prompt-function 'epe-theme-lambda)
(when (featurep 'nyan-prompt)
(nyan-prompt-enable))))
#+END_SRC
*** Show form feeds as a horizontal line

View File

@ -34,18 +34,26 @@
(propertize nyan-prompt-nyan-cat-emoticon
'display nyan-prompt-nyan-cat-image))
(defvar nyan-prompt-original-prompt 'eshell-prompt-function
(defvar nyan-prompt-original-prompt nil
"The eshell prompt function before enabling nyan-prompt")
(defvar nyan-prompt-enabled nil
"t if nyan-prompt is enabled")
(defun eshell-nyan-prompt ()
(concat nyan-prompt-nyan-cat-string " " (funcall nyan-prompt-original-prompt)))
(defun nyan-prompt-disable ()
(setq eshell-prompt-function 'nyan-prompt-original-prompt))
(when nyan-prompt-enabled
(setq nyan-prompt-enabled nil
eshell-prompt-function nyan-prompt-original-prompt)))
;;;###autoload
(defun nyan-prompt-enable ()
(setq eshell-prompt-function 'eshell-nyan-prompt))
(when (not nyan-prompt-enabled)
(setq nyan-prompt-enabled t
nyan-prompt-original-prompt eshell-prompt-function
eshell-prompt-function 'eshell-nyan-prompt)))
(provide 'nyan-prompt)