From 105a97250cef2b6f9eef701f1328bc37a0fd30f9 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Thu, 21 Nov 2024 10:06:05 -0800 Subject: [PATCH] Fix eshell banner when directory is not a git project --- ha-eshell.org | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ha-eshell.org b/ha-eshell.org index 04c4bb1..5647fa3 100644 --- a/ha-eshell.org +++ b/ha-eshell.org @@ -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)) (bg (face-attribute 'default :foreground)) (bg "#c09644") - (dd (thread-last default-directory - (replace-regexp-in-string (getenv "HOME") "~"))) + (dd (replace-regexp-in-string (getenv "HOME") "~" default-directory)) (gs (or (ha-eshell-banner-git-branch) ""))) (condition-case err (concat @@ -1519,16 +1518,17 @@ Whenever I open a shell, I instinctively type =ls= … so why not do that automa (defun ha-eshell-banner-git-branch () "Return simplified Git branch for current directory." - (thread-last "git status --short --branch --ahead-behind 2>/dev/null" - (shell-command-to-list) - (first) - (replace-regexp-in-string - (rx "## " - (group (zero-or-more not-newline)) - (zero-or-more anychar)) - "\\1") - (replace-regexp-in-string - (rx "...") " → "))) + (ignore-errors + (thread-last "git status --short --branch --ahead-behind 2>/dev/null" + (shell-command-to-list) + (first) + (replace-regexp-in-string + (rx "## " + (group (zero-or-more not-newline)) + (zero-or-more anychar)) + "\\1") + (replace-regexp-in-string + (rx "...") " → ")))) #+end_src * 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.