doomemacs/modules/term/eshell/autoload/prompts.el

40 lines
1.3 KiB
EmacsLisp
Raw Normal View History

;;; term/eshell/autoload/prompts.el -*- lexical-binding: t; -*-
;;;###autoload
2019-10-27 13:43:23 -04:00
(defface +eshell-prompt-pwd '((t (:inherit font-lock-constant-face)))
"TODO"
:group 'eshell)
;;;###autoload
2019-10-27 13:43:23 -04:00
(defface +eshell-prompt-git-branch '((t (:inherit font-lock-builtin-face)))
"TODO"
:group 'eshell)
(defun +eshell--current-git-branch ()
;; TODO Refactor me
(cl-destructuring-bind (status . output)
(doom-call-process "git" "symbolic-ref" "-q" "--short" "HEAD")
(if (equal status 0)
(format " [%s]" output)
(cl-destructuring-bind (status . output)
(doom-call-process "git" "describe" "--all" "--always" "HEAD")
(if (equal status 0)
(format " [%s]" output)
"")))))
;;;###autoload
2019-07-23 00:07:14 +02:00
(defun +eshell-default-prompt-fn ()
"Generate the prompt string for eshell. Use for `eshell-prompt-function'."
(require 'shrink-path)
(concat (if (bobp) "" "\n")
2018-06-28 19:29:26 +02:00
(let ((pwd (eshell/pwd)))
(propertize (if (equal pwd "~")
pwd
(abbreviate-file-name (shrink-path-file pwd)))
'face '+eshell-prompt-pwd))
(propertize (+eshell--current-git-branch)
'face '+eshell-prompt-git-branch)
(propertize " λ" 'face (if (zerop eshell-last-command-status) 'success 'error))
" "))