term/eshell: optimize branch display in prompt #1882

This commit is contained in:
Henrik Lissner 2019-10-17 02:40:53 -04:00
parent 2485cac2e0
commit 3e947d39b5
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -12,11 +12,10 @@
(defun +eshell--current-git-branch () (defun +eshell--current-git-branch ()
(let ((branch (car (cl-loop for match in (split-string (shell-command-to-string "git branch") "\n") (cl-destructuring-bind (status . output)
if (string-match-p "^\*" match) (doom-call-process "git" "name-rev" "--name-only" "HEAD")
collect match)))) (if (equal status 0)
(if (not (eq branch nil)) (format " [%s]" output)
(format " [%s]" (substring branch 2))
""))) "")))
;;;###autoload ;;;###autoload