diff options
| -rw-r--r-- | emacs-config.org | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/emacs-config.org b/emacs-config.org index 35a2528..889d0f3 100644 --- a/emacs-config.org +++ b/emacs-config.org @@ -1223,6 +1223,86 @@ Make shell prompt and output read-only. '(read-only t rear-nonsticky (inhibit-line-move-field-capture))))) #+end_src +** Eshell +Set the eshell welcome message. +#+begin_src elisp + (with-eval-after-load 'em-banner + (setq-default eshell-banner-message "")) +#+end_src + +Set the prompt for eshell. +#+begin_src elisp :noweb yes + (with-eval-after-load 'em-prompt + <<eshell-prompt>>) +#+end_src + +**** Eshell Prompt +:PROPERTIES: +:header-args:elisp: :tangle no :noweb-ref eshell-prompt :results none +:ID: 531f8b73-c91a-449d-a13b-2bddc8fe13c7 +:END: + +Prompt faces. +#+begin_src elisp + (defface +eshell-user + '((t :foreground "DodgerBlue" :weight bold)) + "The face used to highlight $USER." + :group 'eshell-prompt) + + (defface +eshell-host + '((t :foreground "indianred" :weight bold)) + "The face used to highlight $HOSTNAME." + :group 'eshell-prompt) + + (defface +eshell-dir + '((t :foreground "goldenrod" :weight bold)) + "The face used to highlight $PWD." + :group 'eshell-prompt) + + (defface +eshell-branch + '((t :foreground "MediumSeaGreen" :weight bold)) + "The face used to highlight the Git branch." + :group 'eshell-prompt) + + (set-face-attribute 'eshell-prompt nil :inherit 'default) +#+end_src + +Prompt functions. +#+begin_src elisp + (require 'vc-git) + (defun +eshell-git-branch () + "Get the Git branch for the current working directory." + (vc-git--symbolic-ref (eshell/pwd))) + + (defun +eshell-dir (&optional limit) + "Get full directory path or restrict to current folder if LIMIT." + (if limit + (file-name-nondirectory (abbreviate-file-name (eshell/pwd))) + (abbreviate-file-name (eshell/pwd)))) + + (defun +eshell-prompt-layout (user dir host branch) + "Return a prompt layout using USER, DIR, HOST, & BRANCH." + (propertize + (concat + "[" user "@" host " in " dir (when branch (concat " on " branch)) "] "))) + + (defun +eshell-prompt-function () + "Custom eshell prompt function." + (let ((branch (+eshell-git-branch))) + (+eshell-prompt-layout + (propertize (eshell-user-name) 'face '+eshell-user) + (propertize (+eshell-dir t) 'face '+eshell-dir) + (propertize (system-name) 'face '+eshell-host) + (when branch (propertize branch 'face '+eshell-branch))))) +#+end_src + +Prompt settings. +#+begin_src elisp + (setq-default + eshell-highlight-prompt nil + eshell-prompt-function #'+eshell-prompt-function) +#+end_src + * Keybindings Unlock previously unusable keybinding. #+begin_src elisp |
