diff options
| -rw-r--r-- | bard-elisp/bard-eshell.el | 54 | ||||
| -rw-r--r-- | bard-emacs-modules/bard-emacs-eshell.el | 10 |
2 files changed, 63 insertions, 1 deletions
diff --git a/bard-elisp/bard-eshell.el b/bard-elisp/bard-eshell.el index 9625a13..e50a707 100644 --- a/bard-elisp/bard-eshell.el +++ b/bard-elisp/bard-eshell.el @@ -1,6 +1,20 @@ (require 'cl-lib) (require 'eshell) +;; aliases +(setq bard/eshell-aliases + '((g . magit) + (gl . magit-log) + (d . dired) + (o . find-file) + (oo . find-file-other-window) + (l . (lambda () (eshell/ls '-la))) + (eshell/clear . eshell/clear-scrollback))) + +(mapc (lambda (alias) + (defalias (car alias) (cdr alias))) + bard/eshell-aliases) + (defun prot-eshell--cd (dir) "Routine to cd into DIR." (delete-region eshell-last-output-end (point-max)) @@ -117,4 +131,44 @@ append to it, while separating multiple outputs with ((not in-eshellp) (switch-to-buffer (car buffers))) (t (select-or-create (completing-read "Select Shell:" (cons "New eshell" names))))))) +;; taken from https://github.com/karthink/.emacs.d/blob/master/lisp/setup-shells.el +(use-package eshell + :defer + :config + (setq eshell-prompt-regexp "^.* λ " + eshell-prompt-function #'bard/eshell-default-prompt-fn) + + (defun bard/eshell-default-prompt-fn () + "Generate the prompt string for eshell. Use for `eshell-prompt-function'." + (concat (if (bobp) "" "\n") + (let ((pwd (eshell/pwd))) + (propertize (if (equal pwd "~") + pwd + (abbreviate-file-name pwd)) + 'face 'bard/eshell-prompt-pwd)) + (propertize (bard/eshell--current-git-branch) + 'face 'bard/eshell-prompt-git-branch) + (propertize " λ" 'face (if (zerop eshell-last-command-status) 'success 'error)) + " ")) + + (defsubst bard/eshell--current-git-branch () + ;; TODO Refactor me + (cl-destructuring-bind (status . output) + (with-temp-buffer (cons + (or (call-process "git" nil t nil "symbolic-ref" "-q" "--short" "HEAD") + (call-process "git" nil t nil "describe" "--all" "--always" "HEAD") + -1) + (string-trim (buffer-string)))) + (if (equal status 0) + (format " [%s]" output) + ""))) + + (defface bard/eshell-prompt-pwd '((t (:inherit font-lock-keyword-face))) + "TODO" + :group 'eshell) + + (defface bard/eshell-prompt-git-branch '((t (:inherit font-lock-builtin-face))) + "TODO" + :group 'eshell)) + (provide 'bard-eshell) diff --git a/bard-emacs-modules/bard-emacs-eshell.el b/bard-emacs-modules/bard-emacs-eshell.el index b129ac0..726cf94 100644 --- a/bard-emacs-modules/bard-emacs-eshell.el +++ b/bard-emacs-modules/bard-emacs-eshell.el @@ -1,7 +1,15 @@ (use-package eshell :ensure t :config - (setq eshell-banner-message "Time for another recreational programming session.\n\n")) + ;; (setq eshell-banner-message "Time for another recreational programming session.\n\n") + (setq eshell-banner-message + '(format "%s %s\n %s\n" + (propertize (format " %s " (string-trim (buffer-name))) + 'face 'mode-line-highlight) + (propertize (current-time-string) + 'face 'font-lock-keyword-face) + (propertize "Time for another recreational programming session." + 'face 'warning)))) (define-key global-map (kbd "C-z e") #'eshell-switcher) (with-eval-after-load "esh-mode" |
