From 0d46350ddaf8a47c65483ffd2cbdbf69e6c1d63d Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Wed, 15 Jan 2020 16:29:15 -0500 Subject: [PATCH] Add git branch to eshell prompt --- emacs/init.org | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/emacs/init.org b/emacs/init.org index 8b7a4ca..e5e85a1 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -279,7 +279,7 @@ A framework for creating Magit-style popups: Magit is objectively the best Git interface. #+BEGIN_SRC emacs-lisp (use-package magit - :commands (magit-status magit-blame magit-find-file)) + :commands (magit-status magit-blame magit-find-file magit-name-local-branch)) #+END_SRC #+BEGIN_SRC emacs-lisp @@ -1964,6 +1964,21 @@ Some aliases: (eshell/alias (car alias) (cdr alias))))) #+END_SRC +** Prompt +#+BEGIN_SRC emacs-lisp + (defun jdormit-eshell-prompt () + (let ((branch (magit-name-local-branch "HEAD"))) + (format "%s%s" + (if branch (format "(%s) " branch) "") + (concat (abbreviate-file-name (eshell/pwd)) + (if (= (user-uid) 0) " # " " $ "))))) + + (setq jdormit-eshell-prompt-regex "^[^#$\n]* [#$] ") + + (setq eshell-prompt-function 'jdormit-eshell-prompt) + (setq eshell-prompt-regexp jdormit-eshell-prompt-regex) +#+END_SRC + * Flycheck Syntax checking etc.: #+BEGIN_SRC emacs-lisp