Add eshell config

This commit is contained in:
Alexander Rosenberg 2023-11-06 02:34:54 -08:00
parent 2832882544
commit 7dae839ad6
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

67
init.el
View File

@ -678,6 +678,73 @@ COMMAND and COMINT are like `compile'."
(use-package vterm
:hook (vterm-mode . with-editor-export-editor))
;; eat (mostly for eshell purposes)
(use-package eat)
;; eshell stuff
(use-package eshell
:ensure nil
:defer nil
:hook ((eshell-mode . my/-eshell-local-init-alias-hook)
(eshell-mode . my/eshell-update-aliases)
(eshell-load . eat-eshell-visual-command-mode)
(eshell-load . eat-eshell-mode))
:init
(setq-default eshell-command-aliases-list
'(("clear" "clear t" 0 7 (escaped t))))
(defvar my/eshell-aliases
'(("ls" . "eza --git -F")
("la" . "ls -a"))
"Aliases for eshell that work better than the default.")
(defun my/-eshell-resolve-alias (name)
"Recursively resolve an alias, NAME, from `my/eshell-aliases'."
(if-let ((entry (assoc name my/eshell-aliases))
(def (split-string-and-unquote (cdr entry))))
(if-let (sub-def (my/-eshell-resolve-alias (car def)))
(append sub-def (cdr def))
def)))
(defun my/eshell-update-aliases ()
"Update aliases in `my/eshell-aliases'."
(interactive)
(dolist (entry my/eshell-aliases)
(when-let ((sym (intern (concat "eshell/" (car entry))))
(def (my/-eshell-resolve-alias (car entry))))
(defalias sym
#'(lambda (&rest args)
(eshell-flush -1)
(throw 'eshell-external
(eshell-external-command (car def)
(append (cdr def) args)))
(eshell-flush))
(concat "Eshell alias for \"" (s-join " " def) "\"")))))
(defun my/-eshell-local-init-alias-hook ()
"Run from `eshell-mode-hook' to initialize aliases."
(dolist (entry my/eshell-aliases)
(add-to-list 'eshell-complex-commands (car entry))))
(defun my/-eshell-lookup-my-alias-first (oldfun name)
"Advice around `eshell-lookup-alias' to also lookup aliases from `my/eshell-aliases'."
(if-let (def (my/-eshell-resolve-alias name))
(list name (s-join " " def))
(funcall oldfun name)))
(advice-add 'eshell-lookup-alias :around #'my/-eshell-lookup-my-alias-first)
(defun my/-eshell-ignore-alias-file (oldfun)
"Ignore aliases in `eshell-aliases-file'"
(let ((eshell-command-aliases-list nil))
(funcall oldfun)))
(advice-add 'eshell-alias-initialize :around #'my/-eshell-ignore-alias-file))
(use-package esh-help
:hook (eshell-mode . my/-setup-eshell-help-func)
:init
(defun my/-setup-eshell-help-func ()
(eldoc-mode 1)
(setq-local evil-lookup-func #'esh-help-run-help))
(setup-esh-help-eldoc))
(use-package esh-autosuggest
:hook (eshell-mode . esh-autosuggest-mode))
(use-package eshell-syntax-highlighting
:init
(eshell-syntax-highlighting-global-mode 1))
;; proced
(use-package proced
:bind ("C-x j" . proced)