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 ()
(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