[Emacs] Eshell prompt update

This commit removes the banner displayed on Eshell launch. I will
maybe do something with it one day similar to my fish_greeting
function for the fish shell.

The git prompt now also separates the current path in half if we are
in a git repository: the path up to the repository, the git prompt,
and then the relative path to the repo is are shown in that order.
To achieve that, `phundrak/is-dir-a-git-repo' has been modified to
return either the path to the git repo or `nil'.
This commit is contained in:
Lucien Cartier-Tilet 2020-11-06 14:41:29 +01:00
parent d40de0fdec
commit caba458431
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
2 changed files with 21 additions and 6 deletions

View File

@ -149,7 +149,8 @@ This function is called at the very end of Spacemacs initialization."
(cons 320 "#6f4e52") (cons 320 "#6f4e52")
(cons 340 "#5B6268") (cons 340 "#5B6268")
(cons 360 "#5B6268"))) (cons 360 "#5B6268")))
'(vc-annotate-very-old-color nil)) '(vc-annotate-very-old-color nil)
'(warning-suppress-log-types '((comp))))
(custom-set-faces (custom-set-faces
;; custom-set-faces was added by Custom. ;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.

View File

@ -1600,11 +1600,11 @@
directory or to one of its subdirectories. directory or to one of its subdirectories.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun phundrak/is-dir-a-git-repo ($path) (defun phundrak/is-dir-a-git-repo ($path)
"Return `t' if `$path' points to a git repository or one of its "Return `$path' if it points to a git repository or one of its
subdirectories" subdirectories"
(when $path (when $path
(if (f-dir? (concat $path "/.git")) (if (f-dir? (concat $path "/.git"))
t $path
(phundrak/is-dir-a-git-repo (f-parent $path))))) (phundrak/is-dir-a-git-repo (f-parent $path)))))
#+END_SRC #+END_SRC
@ -1950,17 +1950,25 @@
failure respectively." failure respectively."
(let* ((header-bg phundrak/nord0) (let* ((header-bg phundrak/nord0)
($path (phundrak/abbr-path (eshell/pwd))) ($path (phundrak/abbr-path (eshell/pwd)))
($git-path (phundrak/is-dir-a-git-repo $path))
($abbr-path (phundrak/abbr-path $path phundrak/prompt--abbreviate)) ($abbr-path (phundrak/abbr-path $path phundrak/prompt--abbreviate))
($background phundrak/nord1) ($background phundrak/nord1)
($foreground phundrak/nord14) ($foreground phundrak/nord14)
($success phundrak/nord10) ($success phundrak/nord10)
($error phundrak/nord11)) ($error phundrak/nord11))
(concat (with-face (concat " " $abbr-path " ") (concat (with-face (concat " " (phundrak/var-or-if-nil $git-path $path) " ")
:foreground $foreground :foreground $foreground
:background $background) :background $background)
(when (phundrak/is-dir-a-git-repo $path) (when $git-path
(concat (phundrak/eshell-git-status $path $background) (concat (phundrak/eshell-git-status $path $background)
(with-face " " :background $background))) (with-face (format "%s "
(let (($in-git-path (phundrak/abbr-path (f-relative $path $git-path)
phundrak/prompt--abbreviate)))
(if (string= "." $in-git-path)
""
(concat " " $in-git-path))))
:foreground $foreground
:background $background)))
(with-face "λ " (with-face "λ "
:foreground (if (zerop eshell-last-command-status) :foreground (if (zerop eshell-last-command-status)
$success $success
@ -1976,6 +1984,12 @@
eshell-prompt-function 'phundrak/eshell-prompt) eshell-prompt-function 'phundrak/eshell-prompt)
#+END_SRC #+END_SRC
I also don't want the banner to be displayed, I know I entered the Elisp
shell, no need to remind me. Maybe Ill do something with it one day.
#+BEGIN_SRC emacs-lisp
(setq eshell-banner-message "")
#+END_SRC
*** Org-mode *** Org-mode
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User_Configuration-Org-mode-04ab8ad3 :CUSTOM_ID: User_Configuration-Org-mode-04ab8ad3