From 3e947d39b51aa18b634c09f232a9533b56a5b2cc Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 17 Oct 2019 02:40:53 -0400 Subject: [PATCH] term/eshell: optimize branch display in prompt #1882 --- modules/term/eshell/autoload/prompts.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/term/eshell/autoload/prompts.el b/modules/term/eshell/autoload/prompts.el index 3a9638d09..c2f01a4cc 100644 --- a/modules/term/eshell/autoload/prompts.el +++ b/modules/term/eshell/autoload/prompts.el @@ -12,11 +12,10 @@ (defun +eshell--current-git-branch () - (let ((branch (car (cl-loop for match in (split-string (shell-command-to-string "git branch") "\n") - if (string-match-p "^\*" match) - collect match)))) - (if (not (eq branch nil)) - (format " [%s]" (substring branch 2)) + (cl-destructuring-bind (status . output) + (doom-call-process "git" "name-rev" "--name-only" "HEAD") + (if (equal status 0) + (format " [%s]" output) ""))) ;;;###autoload