dotfiles/emacs/.emacs.d/config/init-eshell.el

51 lines
1.6 KiB
EmacsLisp
Raw Normal View History

2021-02-21 02:59:11 +00:00
;; -*- lexical-binding: t; -*-
2021-02-20 19:58:31 +00:00
(use-package eshell
:straight (:type built-in)
:config
;; Easy binding to get an eshell
(defun open-eshell (&optional arg)
(interactive "P")
(if (and (fboundp 'projectile-project-root)
(projectile-project-root))
(projectile-run-eshell arg)
(eshell arg)))
;; Actually clear the eshell buffer
(defun clear-eshell (&optional prefix)
(interactive)
(let ((input (eshell-get-old-input)))
(eshell/clear-scrollback)
(eshell-emit-prompt)
(insert input)))
(add-hook 'eshell-mode-hook
(lambda () (general-def eshell-mode-map "C-c C-o" #'clear-eshell)))
(evil-collection-eshell-setup)
;; Gotta have a good prompt
(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))
" "
(propertize
(if (= (user-uid) 0) "#" "λ")
'face `(:foreground "#859900"))
" "))))
(setq jdormit-eshell-prompt-regex "^[^#λ\n]* [#λ] ")
(setq eshell-prompt-function 'jdormit-eshell-prompt)
(setq eshell-prompt-regexp jdormit-eshell-prompt-regex)
2021-02-21 03:21:49 +00:00
;; Load dir-locals when switching directories
(add-hook 'eshell-mode-hook #'hack-dir-local-variables-non-file-buffer)
(add-hook 'eshell-after-prompt-hook #'hack-dir-local-variables-non-file-buffer)
2021-02-20 19:58:31 +00:00
:general
(leader-map "'" #'open-eshell)
:custom
(eshell-cmpl-cycle-completions nil))
(provide 'init-eshell)