2019-05-18 23:41:18 -04:00
|
|
|
;;; term/eshell/autoload/prompts.el -*- lexical-binding: t; -*-
|
2018-06-18 22:31:27 +02:00
|
|
|
|
|
|
|
;;;###autoload
|
2019-10-27 13:43:23 -04:00
|
|
|
(defface +eshell-prompt-pwd '((t (:inherit font-lock-constant-face)))
|
2018-06-18 22:31:27 +02:00
|
|
|
"TODO"
|
|
|
|
:group 'eshell)
|
|
|
|
|
|
|
|
;;;###autoload
|
2019-10-27 13:43:23 -04:00
|
|
|
(defface +eshell-prompt-git-branch '((t (:inherit font-lock-builtin-face)))
|
2018-06-18 22:31:27 +02:00
|
|
|
"TODO"
|
|
|
|
:group 'eshell)
|
|
|
|
|
|
|
|
|
|
|
|
(defun +eshell--current-git-branch ()
|
2020-01-23 01:59:20 -05:00
|
|
|
;; TODO Refactor me
|
2019-10-17 02:40:53 -04:00
|
|
|
(cl-destructuring-bind (status . output)
|
2020-01-23 01:59:20 -05:00
|
|
|
(doom-call-process "git" "symbolic-ref" "-q" "--short" "HEAD")
|
2019-10-17 02:40:53 -04:00
|
|
|
(if (equal status 0)
|
|
|
|
(format " [%s]" output)
|
2020-01-23 01:59:20 -05:00
|
|
|
(cl-destructuring-bind (status . output)
|
|
|
|
(doom-call-process "git" "describe" "--all" "--always" "HEAD")
|
|
|
|
(if (equal status 0)
|
|
|
|
(format " [%s]" output)
|
|
|
|
"")))))
|
2018-06-18 22:31:27 +02:00
|
|
|
|
|
|
|
;;;###autoload
|
2019-07-23 00:07:14 +02:00
|
|
|
(defun +eshell-default-prompt-fn ()
|
2018-06-18 22:31:27 +02:00
|
|
|
"Generate the prompt string for eshell. Use for `eshell-prompt-function'."
|
2019-10-19 16:51:47 -04:00
|
|
|
(require 'shrink-path)
|
2018-06-18 22:31:27 +02:00
|
|
|
(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))
|
2018-06-18 22:31:27 +02:00
|
|
|
(propertize (+eshell--current-git-branch)
|
|
|
|
'face '+eshell-prompt-git-branch)
|
|
|
|
(propertize " λ" 'face (if (zerop eshell-last-command-status) 'success 'error))
|
|
|
|
" "))
|