From 4cabfc0c8f91332da2d1cc4f10b4d8a5dd637606 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Tue, 3 Jun 2025 00:34:19 +0100 Subject: Updates, loads of updates! --- Emacs/.config/emacs/elisp/elfeed-org.el | 20 ++--- Emacs/.config/emacs/elisp/eshell-additions.el | 15 +++- Emacs/.config/emacs/elisp/eshell-prompt.el | 89 +++++++++++++++-------- Emacs/.config/emacs/elisp/personal-light-theme.el | 13 ++++ 4 files changed, 94 insertions(+), 43 deletions(-) (limited to 'Emacs/.config/emacs/elisp') diff --git a/Emacs/.config/emacs/elisp/elfeed-org.el b/Emacs/.config/emacs/elisp/elfeed-org.el index 2b68acc..4416926 100644 --- a/Emacs/.config/emacs/elisp/elfeed-org.el +++ b/Emacs/.config/emacs/elisp/elfeed-org.el @@ -29,11 +29,12 @@ (defun elfeed-org/--parse-link (context) (thread-last (org-element-property :title context) search-forward) - (let ((title-context (org-element-context))) - (org-element-property :raw-link title-context))) + (org-element-property :raw-link (org-element-context))) (defun elfeed-org/--parse-tags () - (mapcar #'intern (org-get-tags))) + (thread-last + (org-get-tags) + (mapcar #'intern))) (defun elfeed-org/--parse-headline () (if-let* ((ctx (org-element-context)) @@ -43,14 +44,15 @@ nil)) (defun elfeed-org/--parse-headlines () - (cl-remove-if - #'null - (org-map-entries #'elfeed-org/--parse-headline t))) + (thread-last + (org-map-entries #'elfeed-org/--parse-headline t) + (cl-remove-if #'null))) (defun elfeed-org () - (setq elfeed-feeds - (with-current-buffer (find-file-noselect elfeed-org/file) - (elfeed-org/--parse-headlines)))) + (thread-last + (elfeed-org/--parse-headlines) + (with-current-buffer (find-file-noselect elfeed-org/file)) + (setq elfeed-feeds))) (provide 'elfeed-org) ;;; elfeed-org.el ends here diff --git a/Emacs/.config/emacs/elisp/eshell-additions.el b/Emacs/.config/emacs/elisp/eshell-additions.el index a9362db..2d53610 100644 --- a/Emacs/.config/emacs/elisp/eshell-additions.el +++ b/Emacs/.config/emacs/elisp/eshell-additions.el @@ -41,14 +41,23 @@ "Change to directory `project-root'" (if (project-current) (eshell/cd (list (project-root (project-current)))) + (setq eshell-last-command-status 1) (eshell/echo (format "[%s]: No project in current directory" (propertize "Error" 'font-lock-face '(:foreground "red")))))) (defun eshell/sudo-switch (&rest args) - "Switch to a tramp connection sudo in the current directory" - (let ((wrapped-dir (concat "/sudo::" default-directory))) - (eshell/cd wrapped-dir))) + "Switch to and from administrative (sudo) mode in Eshell. +Uses tramp to figure out if we're in sudo mode or not. " + (let ((user (file-remote-p default-directory 'user))) + (cond + ((null user) + (let ((wrapped-dir (concat "/sudo::" default-directory))) + (eshell/cd wrapped-dir))) + ((string= user "root") + (thread-last 'localname + (file-remote-p default-directory) + eshell/cd))))) ;; Additional functions (defun +eshell/at-cwd (&optional arg) diff --git a/Emacs/.config/emacs/elisp/eshell-prompt.el b/Emacs/.config/emacs/elisp/eshell-prompt.el index dafd8ea..af5c55f 100644 --- a/Emacs/.config/emacs/elisp/eshell-prompt.el +++ b/Emacs/.config/emacs/elisp/eshell-prompt.el @@ -19,25 +19,29 @@ ;;; Commentary: -;; We provide a function +eshell-prompt which generates a prompt on +;; We provide a function ep which generates a prompt on ;; demand. ;;; Code: -(defvar +eshell-prompt/user-prompt "𝜆> " +(defvar ep/user-prompt " λ " "Prompt for user to input.") -(defvar +eshell-prompt/dir-colour "deepskyblue") -(defvar +eshell-prompt/success-colour "forestgreen") -(defvar +eshell-prompt/failure-colour "red") +(defvar ep/dir-colour "deepskyblue") +(defvar ep/success-colour "forestgreen") +(defvar ep/failure-colour "red") +(defvar ep/branch-name-colour "LightSalmon") +(defvar ep/pipe-colour "green2") +(defvar ep/ahead-colour "dodger blue") +(defvar ep/remote-colour "DarkGoldenrod") -(defun +eshell-prompt/--colour-on-last-command () +(defun ep/--colour-on-last-command () "Returns an Emacs colour based on ESHELL-LAST-COMMAND-STATUS." (if (zerop eshell-last-command-status) - +eshell-prompt/success-colour - +eshell-prompt/failure-colour)) + ep/success-colour + ep/failure-colour)) -(defun +eshell-prompt/--git-remote-status () +(defun ep/--git-remote-status () "Returns a propertized string for the status of a repository in comparison to its remote. 3 differing strings are returned dependent on: @@ -53,17 +57,17 @@ 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 ,+eshell-prompt/success-colour)) + (propertize "=" 'font-lock-face `(:foreground ,ep/success-colour)) (let ((n (nth (+ 1 diff) branch-status))) (concat (cond ((string= status "ahead") - (propertize "→" 'font-lock-face '(:foreground "dodger blue"))) + (propertize "→" 'font-lock-face `(:foreground ,ep/ahead-colour))) ((string= status "behind") - (propertize "←" 'font-lock-face '(:foreground "red")))) + (propertize "←" 'font-lock-face `(:foreground ,ep/failure-colour)))) n))))) -(defun +eshell-prompt/--git-change-status () +(defun ep/--git-change-status () "Returns a propertized string for the condition of the worktree in a repository. If there are no changes i.e. the worktree is clean then a green tick is returned, but if there are changes then the @@ -74,12 +78,13 @@ number of files affected are returned in red." (if (= changed-files 0) (propertize "✓" 'font-lock-face - `(:foreground ,+eshell-prompt/success-colour)) + `(:foreground ,ep/success-colour)) (propertize (number-to-string changed-files) 'font-lock-face - `(:foreground ,+eshell-prompt/failure-colour))))) + `(:foreground ,ep/failure-colour))))) -(defun +eshell-prompt/--git-branch-name () +(defun ep/--git-branch-name () + "Get the branch name of the current working directory. W" (let* ((branch-name (thread-last (split-string (shell-command-to-string "git branch") "\n") (cl-remove-if (lambda (s) (= (length s) 0))) @@ -89,23 +94,34 @@ number of files affected are returned in red." (cond ((null branch-name) nil) ((string= "(" (substring branch-name 0 1)) - (replace-regexp-in-string "\\(.*at \\)\\|)" "" branch-name)) + (replace-regexp-in-string + "\n$" "" + (shell-command-to-string "git rev-parse --short HEAD"))) (t branch-name)))) -(defun +eshell-prompt/--git-status () +(defun ep/--git-status () "Returns a completely formatted string of -form (BRANCH-NAME[REMOTE-STATUS])." - (let ((git-branch (+eshell-prompt/--git-branch-name))) + form (BRANCH-NAME[REMOTE-STATUS])." + (let ((git-branch (ep/--git-branch-name))) (if (null git-branch) "" (format - "(%s<%s>[%s])" - git-branch - (+eshell-prompt/--git-change-status) - (+eshell-prompt/--git-remote-status))))) - -(defun +eshell-prompt/make-prompt () - (let ((git (+eshell-prompt/--git-status))) + "%s(%s)(%s)" + (propertize git-branch 'font-lock-face `(:foreground ,ep/branch-name-colour)) + (ep/--git-remote-status) + (ep/--git-change-status))))) + +(defun ep/--user-and-remote () + (if (file-remote-p default-directory) + (let ((user (file-remote-p default-directory 'user)) + (host (file-remote-p default-directory 'host))) + (if user + (format "%s@%s " user host) + (concat host " "))) + "")) + +(defun ep/make-prompt () + (let ((git (ep/--git-status))) (mapconcat (lambda (item) (if (listp item) @@ -115,15 +131,26 @@ form (BRANCH-NAME[REMOTE-STATUS])." 'rear-nonsticky '(font-lock-face read-only)) item)) (list + `("┌──" + :foreground ,ep/pipe-colour) "[" - `(,(abbreviate-file-name (eshell/pwd)) :foreground ,+eshell-prompt/dir-colour) - "]" + `(,(ep/--user-and-remote) + :foreground ,ep/remote-colour) + `(,(abbreviate-file-name (tramp-file-local-name (eshell/pwd))) + :foreground ,ep/dir-colour) (if (string= git "") "" - (concat " " git)) + (concat "]─[" git)) + "]" "\n" - (list "𝜆> " ':foreground (+eshell-prompt/--colour-on-last-command)))))) + `("└─>" + :foreground ,ep/pipe-colour) + (list ep/user-prompt ':foreground (ep/--colour-on-last-command)))))) (provide 'eshell-prompt) ;;; eshell-prompt.el ends here + +;; Local Variables: +;; read-symbol-shorthands: (("ep" . "+eshell-prompt")) +;; End: diff --git a/Emacs/.config/emacs/elisp/personal-light-theme.el b/Emacs/.config/emacs/elisp/personal-light-theme.el index c8e4f3e..d05f880 100644 --- a/Emacs/.config/emacs/elisp/personal-light-theme.el +++ b/Emacs/.config/emacs/elisp/personal-light-theme.el @@ -81,6 +81,19 @@ '(org-quote ((t (:slant italic)))) '(org-verbatim ((t (:foreground "red3")))) '(query-replace ((t (:inherit (isearch))))) + '(rainbow-delimiters-base-error-face ((t (:extend t :foreground "white" + :background "red1")))) + '(rainbow-delimiters-depth-1-face ((t (:extend t :foreground "red")))) + '(rainbow-delimiters-depth-2-face ((t (:extend t :foreground "darkorange")))) + '(rainbow-delimiters-depth-3-face ((t (:extend t :foreground "yellow")))) + '(rainbow-delimiters-depth-4-face ((t (:extend t :foreground "green")))) + '(rainbow-delimiters-depth-5-face ((t (:extend t :foreground "DeepSkyBlue")))) + '(rainbow-delimiters-depth-6-face ((t (:extend t :foreground "purple")))) + '(rainbow-delimiters-depth-7-face ((t (:extend t :foreground "violet")))) + '(rainbow-delimiters-mismatched-face ((t (:extend t :foreground "white" + :background "red4")))) + '(rainbow-delimiters-unmatched-face ((t (:extend t :foreground "white" + :background "red3")))) '(region ((t (:extend t :background "#C2D5E9")))) '(secondary-selection ((((class color) (min-colors 88) (background light)) (:extend t :background "yellow1")) (((class color) (min-colors 88) (background dark)) (:extend t :background "SkyBlue4")) (((class color) (min-colors 16) (background light)) (:extend t :background "yellow")) (((class color) (min-colors 16) (background dark)) (:extend t :background "SkyBlue4")) (((class color) (min-colors 8)) (:extend t :foreground "black" :background "cyan")) (t (:inverse-video t)))) '(shadow ((((class color grayscale) (min-colors 88) (background light)) -- cgit v1.2.3-13-gbd6f