summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmin Bandali <bandali@gnu.org>2018-11-11 22:47:57 -0500
committerAmin Bandali <bandali@gnu.org>2018-11-11 22:49:02 -0500
commit6827bbb0cbb1d792911811bcfd1739c5817db2b1 (patch)
tree6b6ba58628b161edf869c03a6d441b10220fb467
parent54c1fbaca23737a86679f767c0c9dcac48bde74f (diff)
downloadconfigs-6827bbb0cbb1d792911811bcfd1739c5817db2b1.tar.gz
configs-6827bbb0cbb1d792911811bcfd1739c5817db2b1.tar.xz
configs-6827bbb0cbb1d792911811bcfd1739c5817db2b1.zip
[emacs] customize the eshell prompt
adapted from https://gitlab.com/bennya/shrink-path.el
Diffstat (limited to '')
-rw-r--r--init.org31
1 files changed, 31 insertions, 0 deletions
diff --git a/init.org b/init.org
index d4da17d..127926d 100644
--- a/init.org
+++ b/init.org
@@ -1782,6 +1782,37 @@ Hopefully temporary.
(global-hl-todo-mode))
#+end_src
+** shrink-path
+
+#+begin_src emacs-lisp
+(use-package shrink-path
+ :after eshell
+ :config
+ (setq eshell-prompt-regexp "\\(.*\n\\)*λ "
+ eshell-prompt-function #'+eshell/prompt)
+
+ (defun +eshell/prompt ()
+ (let ((base/dir (shrink-path-prompt default-directory)))
+ (concat (propertize (car base/dir)
+ 'face 'font-lock-comment-face)
+ (propertize (cdr base/dir)
+ 'face 'font-lock-constant-face)
+ (propertize (+eshell--current-git-branch)
+ 'face 'font-lock-function-name-face)
+ "\n"
+ (propertize "λ" 'face 'eshell-prompt-face)
+ ;; needed for the input text to not have prompt face
+ (propertize " " 'face 'default))))
+
+ (defun +eshell--current-git-branch ()
+ (let ((branch (car (loop for match in (split-string (shell-command-to-string "git branch") "\n")
+ when (string-match "^\*" match)
+ collect match))))
+ (if (not (eq branch nil))
+ (concat " " (substring branch 2))
+ ""))))
+#+end_src
+
* Email
#+begin_src emacs-lisp