;; -*- lexical-binding: t; -*- (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) :general (leader-map "'" #'open-eshell) :custom (eshell-cmpl-cycle-completions nil)) (provide 'init-eshell)