From 337d8090f3ef71ccc16fcc70019cf3ce2a3bf94a Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 24 Aug 2023 11:20:01 +0000 Subject: Add custom eshell git prompt --- emacs.org | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/emacs.org b/emacs.org index 6d44531..7cea165 100755 --- a/emacs.org +++ b/emacs.org @@ -1058,7 +1058,36 @@ Create function to watch videos using ~mpv~ #+end_src ** Prompt #+begin_src emacs-lisp + ;; customize multiline theme + (defun eshell-git-prompt-multiline () + "Eshell Git prompt inspired by spaceship-prompt." + (let (separator hr dir git git-dirty time sign command) + (setq separator (with-face " | " 'eshell-git-prompt-multiline-secondary-face)) + (setq hr (with-face (concat "\n" (make-string (/ (window-total-width) 2) ?─) "\n") 'eshell-git-prompt-multiline-secondary-face)) + (setq dir + (concat + (concat (abbreviate-file-name (eshell/pwd))))) + (setq git + (concat (with-face "⎇" 'eshell-git-prompt-exit-success-face) + (concat (eshell-git-prompt--branch-name)))) + (setq git-dirty + (when (eshell-git-prompt--branch-name) + (if (eshell-git-prompt--collect-status) + (with-face " ✎" 'eshell-git-prompt-modified-face) + (with-face " ✔" 'eshell-git-prompt-exit-success-face)))) + (setq time (with-face (format-time-string "%I:%M:%S %p") 'eshell-git-prompt-multiline-secondary-face)) + (setq sign + (if (= (user-uid) 0) + (with-face "\n#" 'eshell-git-prompt-multiline-sign-face) + (with-face "\nλ" 'eshell-git-prompt-multiline-sign-face))) + (setq command (with-face " " 'eshell-git-prompt-multiline-command-face)) + + ;; Build prompt + (eshell-git-prompt---str-read-only + (concat hr dir separator git git-dirty separator time sign command)))) + (eshell-git-prompt-use-theme 'multiline) + (eshell-syntax-highlighting-global-mode 1) (setq eshell-highlight-prompt t) -- cgit v1.2.3