Set up eshell

This commit is contained in:
Jeremy Dormitzer 2021-02-20 14:58:31 -05:00
parent a3d4ba6327
commit 983fc50ab4
3 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,44 @@
(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)

View File

@ -1,5 +1,9 @@
;; Magit!
(use-package magit
:commands (magit-status
magit-file-dispatch
magit-dispatch
magit-name-local-branch)
:init
(leader-def-key "g" '(nil :which-key "git"))
:config

View File

@ -54,6 +54,7 @@
(require 'init-projects)
(require 'init-git)
(require 'init-ide)
(require 'init-eshell)
;; Load the custom file
(when (file-exists-p custom-file)