/
nyan-prompt.el
60 lines (44 loc) · 1.64 KB
/
nyan-prompt.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;;; nyan-prompt.el --- Nyan Cat on the eshell prompt.
;; Author: Javier "PuercoPop" Olaechea <pirata@gmail.com>
;; URL: http://github.com/PuercoPop/nyan-prompt
;; Version: 0.2.0
;; Keywords: nyan, cat, lulz, eshell, rainbow
;; Dependencies ((rx 0))
;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Commentary:
;; Usage: (add-hook 'eshell-load-hook 'nyan-prompt-enable)
;; Inspired by from Jacek "TeMPOraL" Zlydach nyan-mode, to make Porter happy.
;; Copying is an act of love, please copy. ♡
;; The xpm taken awesome nyan-mode
;;; Code:
(require 'rx)
(defconst nyan-prompt-dir (file-name-directory
(or load-file-name buffer-file-name)))
(defconst nyan-prompt-nyan-cat-image
(create-image (concat nyan-prompt-dir "img/nyan.xpm")
'xpm nil :ascent 'center))
(defconst nyan-prompt-nyan-cat-emoticon "~=[,,_,,]:3"
"ASCII art representing the nyan-cat.")
(defconst nyan-prompt-nyan-cat-string
(propertize nyan-prompt-nyan-cat-emoticon
'display nyan-prompt-nyan-cat-image))
;;;###autoload
(defun nyan-prompt-enable ()
(setq eshell-prompt-function
(lambda nil
(concat
(abbreviate-file-name
(eshell/pwd))
(if (= (user-uid) 0)
" # "
(concat " " nyan-prompt-nyan-cat-string " "))))
;; Match a string of characters (representing the path) then a space,
;; the nyan ASCII art and then a space.
eshell-prompt-regexp
(rx (and bol
(1+ anything)
" "
"~=[,,_,,]:3"
" "))))
(provide 'nyan-prompt)
;;; nyan-prompt.el ends here