doomemacs/modules/term/eshell/autoload/prompts.el
Henrik Lissner 6c0881c684
nit: revise TODO/FIXME/HACK/REVIEW/etc in comments
Some were outdated, some were incorrectly labeled, others were already
completed, some were missing... Gotta fix them all.

Also, in :ui hl-todo, there are comments that describe how Doom uses
each of these annotations; those have been updated.
2026-03-02 19:45:09 -05:00

39 lines
1.3 KiB
EmacsLisp

;;; term/eshell/autoload/prompts.el -*- lexical-binding: t; -*-
;;;###autoload
(defface +eshell-prompt-pwd '((t (:inherit font-lock-constant-face)))
"TODO"
:group 'eshell)
;;;###autoload
(defface +eshell-prompt-git-branch '((t (:inherit font-lock-builtin-face)))
"TODO"
:group 'eshell)
(defun +eshell--current-git-branch ()
;; REVIEW: 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
(defun +eshell-default-prompt-fn ()
"Generate the prompt string for eshell. Use for `eshell-prompt-function'."
(require 'shrink-path)
(concat (if (bobp) "" "\n")
(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))
" "))