From 6145df8c49291a764d44b1a4580d7e25dcbf9129 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 8 Sep 2024 02:59:58 +0100 Subject: (Emacs/elisp)~variables for colours of success, failure and dir in eshell-prompt --- Emacs/.config/emacs/elisp/eshell-prompt.el | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'Emacs') diff --git a/Emacs/.config/emacs/elisp/eshell-prompt.el b/Emacs/.config/emacs/elisp/eshell-prompt.el index 483f097..b2cf131 100644 --- a/Emacs/.config/emacs/elisp/eshell-prompt.el +++ b/Emacs/.config/emacs/elisp/eshell-prompt.el @@ -27,11 +27,15 @@ (defvar +eshell-prompt/user-prompt "𝜆> " "Prompt for user to input.") +(defvar +eshell-prompt/dir-colour "forestgreen") +(defvar +eshell-prompt/success-colour "forestgreen") +(defvar +eshell-prompt/failure-colour "red") + (defun +eshell-prompt/--colour-on-last-command () "Returns an Emacs colour based on ESHELL-LAST-COMMAND-STATUS." (if (zerop eshell-last-command-status) - "forestgreen" - "darkred")) + +eshell-prompt/success-colour + +eshell-prompt/failure-colour)) (defun +eshell-prompt/--git-remote-status () "Returns a propertized string for the status of a repository @@ -49,14 +53,14 @@ behind or ahead the local repository is." (status (nth 3 branch-status)) (diff (cl-position "by" branch-status :test #'string=))) (if (null diff) - (propertize "=" 'font-lock-face '(:foreground "green")) + (propertize "=" 'font-lock-face `(:foreground ,+eshell-prompt/success-colour)) (let ((n (nth (+ 1 diff) branch-status))) (concat (cond ((string= status "ahead") (propertize "→" 'font-lock-face '(:foreground "dodger blue"))) ((string= status "behind") - (propertize "←" 'font-lock-face '(:foreground "orange red")))) + (propertize "←" 'font-lock-face '(:foreground "red")))) n))))) (defun +eshell-prompt/--git-change-status () @@ -68,8 +72,12 @@ number of files affected are returned in red." (command-output (split-string (shell-command-to-string git-cmd) "\n")) (changed-files (- (length command-output) 1))) (if (= changed-files 0) - (propertize "✓" 'font-lock-face '(:foreground "green")) - (propertize (number-to-string changed-files) 'font-lock-face '(:foreground "red"))))) + (propertize "✓" + 'font-lock-face + `(:foreground ,+eshell-prompt/success-colour)) + (propertize (number-to-string changed-files) + 'font-lock-face + `(:foreground ,+eshell-prompt/failure-colour))))) (defun +eshell-prompt/--git-status () "Returns a completely formatted string of @@ -97,7 +105,7 @@ form (BRANCH-NAME[REMOTE-STATUS])." item)) (list "[" - `(,(abbreviate-file-name (eshell/pwd)) :foreground "LimeGreen") + `(,(abbreviate-file-name (eshell/pwd)) :foreground ,+eshell-prompt/dir-colour) "]" (if (string= git "") "" -- cgit v1.2.3-13-gbd6f