Fix eshell banner when directory is not a git project

This commit is contained in:
Howard Abrams 2024-11-21 10:06:05 -08:00
parent e5891170a0
commit 105a97250c

View file

@ -1502,8 +1502,7 @@ Whenever I open a shell, I instinctively type =ls= … so why not do that automa
(let ((fg (face-attribute 'default :background)) (let ((fg (face-attribute 'default :background))
(bg (face-attribute 'default :foreground)) (bg (face-attribute 'default :foreground))
(bg "#c09644") (bg "#c09644")
(dd (thread-last default-directory (dd (replace-regexp-in-string (getenv "HOME") "~" default-directory))
(replace-regexp-in-string (getenv "HOME") "~")))
(gs (or (ha-eshell-banner-git-branch) ""))) (gs (or (ha-eshell-banner-git-branch) "")))
(condition-case err (condition-case err
(concat (concat
@ -1519,6 +1518,7 @@ Whenever I open a shell, I instinctively type =ls= … so why not do that automa
(defun ha-eshell-banner-git-branch () (defun ha-eshell-banner-git-branch ()
"Return simplified Git branch for current directory." "Return simplified Git branch for current directory."
(ignore-errors
(thread-last "git status --short --branch --ahead-behind 2>/dev/null" (thread-last "git status --short --branch --ahead-behind 2>/dev/null"
(shell-command-to-list) (shell-command-to-list)
(first) (first)
@ -1528,7 +1528,7 @@ Whenever I open a shell, I instinctively type =ls= … so why not do that automa
(zero-or-more anychar)) (zero-or-more anychar))
"\\1") "\\1")
(replace-regexp-in-string (replace-regexp-in-string
(rx "...") " → "))) (rx "...") " → "))))
#+end_src #+end_src
* Shell Windows * Shell Windows
Now that I often need to pop into remote systems to run a shell or commands, I create helper functions to create those buffer windows. Each buffer begins with =eshell=: allowing me to have more than one eshells, typically, one per project. Now that I often need to pop into remote systems to run a shell or commands, I create helper functions to create those buffer windows. Each buffer begins with =eshell=: allowing me to have more than one eshells, typically, one per project.