Adding a fancy prompt for eshell.

This commit is contained in:
Derek Taylor
2024-10-03 20:43:17 -05:00
parent 90e8818cb3
commit 2d52241d45
3 changed files with 53 additions and 15 deletions
+14 -9
View File
@@ -1,8 +1,9 @@
(add-to-list 'load-path "~/.config/emacs/scripts/") (add-to-list 'load-path "~/.config/emacs/scripts/")
(require 'elpaca-setup) ;; The Elpaca Package Manager (require 'elpaca-setup) ;; The Elpaca Package Manager
(require 'buffer-move) ;; Buffer-move for better window management
(require 'app-launchers) ;; Use emacs as a run launcher like dmenu (experimental) (require 'app-launchers) ;; Use emacs as a run launcher like dmenu (experimental)
(require 'buffer-move) ;; Buffer-move for better window management
(require 'eshell-prompt) ;; A fancy prompt for eshell
(use-package all-the-icons (use-package all-the-icons
:ensure t :ensure t
@@ -568,14 +569,14 @@
(eval-after-load 'org-indent '(diminish 'org-indent-mode)) (eval-after-load 'org-indent '(diminish 'org-indent-mode))
(custom-set-faces (custom-set-faces
'(org-level-1 ((t (:inherit outline-1 :height 1.7)))) '(org-level-1 ((t (:inherit outline-1 :height 1.7))))
'(org-level-2 ((t (:inherit outline-2 :height 1.6)))) '(org-level-2 ((t (:inherit outline-2 :height 1.6))))
'(org-level-3 ((t (:inherit outline-3 :height 1.5)))) '(org-level-3 ((t (:inherit outline-3 :height 1.5))))
'(org-level-4 ((t (:inherit outline-4 :height 1.4)))) '(org-level-4 ((t (:inherit outline-4 :height 1.4))))
'(org-level-5 ((t (:inherit outline-5 :height 1.3)))) '(org-level-5 ((t (:inherit outline-5 :height 1.3))))
'(org-level-6 ((t (:inherit outline-5 :height 1.2)))) '(org-level-6 ((t (:inherit outline-5 :height 1.2))))
'(org-level-7 ((t (:inherit outline-5 :height 1.1))))) '(org-level-7 ((t (:inherit outline-5 :height 1.1)))))
(require 'org-tempo) (require 'org-tempo)
@@ -655,6 +656,10 @@
(setq use-dialog-box nil) ;; No dialog box (setq use-dialog-box nil) ;; No dialog box
(setq pop-up-windows nil) ;; No popup windows (setq pop-up-windows nil) ;; No popup windows
(setopt eshell-prompt-function 'fancy-shell)
(setopt eshell-prompt-regexp "^[^#$\n]* [$#] ")
(setopt eshell-highlight-prompt nil)
(use-package eshell-toggle (use-package eshell-toggle
:custom :custom
(eshell-toggle-size-fraction 3) (eshell-toggle-size-fraction 3)
+6 -6
View File
@@ -1,9 +1,4 @@
<<<<<<< HEAD
#+TITLE: DT's GNU Emacs Config #+TITLE: DT's GNU Emacs Config
=======
+TITLE: DT's GNU Emacs Config
>>>>>>> 5ea1b34d7a73b295c19ecae4d963083c5ffac771
#+AUTHOR: Derek Taylor (DT) #+AUTHOR: Derek Taylor (DT)
#+DESCRIPTION: DT's personal Emacs config. #+DESCRIPTION: DT's personal Emacs config.
#+STARTUP: showeverything #+STARTUP: showeverything
@@ -75,8 +70,9 @@ To keep this =config.org= a reasonable length, I have moved a lot of code to ind
** Sourcing the scripts ** Sourcing the scripts
#+begin_src emacs-lisp #+begin_src emacs-lisp
(require 'elpaca-setup) ;; The Elpaca Package Manager (require 'elpaca-setup) ;; The Elpaca Package Manager
(require 'buffer-move) ;; Buffer-move for better window management
(require 'app-launchers) ;; Use emacs as a run launcher like dmenu (experimental) (require 'app-launchers) ;; Use emacs as a run launcher like dmenu (experimental)
(require 'buffer-move) ;; Buffer-move for better window management
(require 'eshell-prompt) ;; A fancy prompt for eshell
#+end_src #+end_src
* ALL THE ICONS * ALL THE ICONS
@@ -956,6 +952,10 @@ In my configs, all of my shells (bash, fish, zsh and the ESHELL) require my shel
Eshell is an Emacs 'shell' that is written in Elisp. Eshell is an Emacs 'shell' that is written in Elisp.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setopt eshell-prompt-function 'fancy-shell)
(setopt eshell-prompt-regexp "^[^#$\n]* [$#] ")
(setopt eshell-highlight-prompt nil)
(use-package eshell-toggle (use-package eshell-toggle
:custom :custom
(eshell-toggle-size-fraction 3) (eshell-toggle-size-fraction 3)
+33
View File
@@ -0,0 +1,33 @@
;;; eshell-prompt.el --- a fancy shell prompt for eshell
;;; Code:
;; fancy-shell
;; A fancy shell prompt for eshell.
(defun fancy-shell ()
"A pretty shell with git status"
(let* ((cwd (abbreviate-file-name (eshell/pwd)))
(ref (magit-get-shortname "HEAD"))
(stat (magit-file-status))
(x-stat eshell-last-command-status)
(git-chunk
(if ref
(format "%s%s%s "
(propertize (if stat "[" "(") 'font-lock-face (list :foreground (if stat "#e81050" "#9bee8b")))
(propertize ref 'font-lock-face '(:foreground "#c897ff"))
(propertize (if stat "]" ")") 'font-lock-face (list :foreground (if stat "#e81050" "#9bee8b"))))
"")))
(propertize
(format "%s %s %s$ "
(if (< 0 x-stat) (format (propertize "!%s" 'font-lock-face '(:foreground "#e81050")) x-stat)
(propertize "" 'font-lock-face (list :foreground (if (< 0 x-stat) "#e81050" "#9bee8b"))))
(propertize cwd 'font-lock-face '(:foreground "#45babf"))
git-chunk)
'read-only t
'front-sticky '(font-lock-face read-only)
'rear-nonsticky '(font-lock-face read-only))))
(provide 'eshell-prompt)
;;; eshell-prompt.el ends here