diff --git a/modules/term/eshell/autoload/commands.el b/modules/term/eshell/autoload/commands.el index 1225270a0..126841f4a 100644 --- a/modules/term/eshell/autoload/commands.el +++ b/modules/term/eshell/autoload/commands.el @@ -28,3 +28,6 @@ For folks with a habit of using \"emacs\" to open files, even in eshell." "Create a directory then cd into it." (make-directory dir t) (eshell/cd dir)) + +;;;###autoload +(defalias 'eshell/help #'+eshell-lookup-documentation) diff --git a/modules/term/eshell/autoload/eshell.el b/modules/term/eshell/autoload/eshell.el index 490283d74..3414e7793 100644 --- a/modules/term/eshell/autoload/eshell.el +++ b/modules/term/eshell/autoload/eshell.el @@ -75,6 +75,21 @@ (insert command) (eshell-send-input nil t)))) +;; Adapted from `esh-help-run-help' +;;;###autoload +(defun +eshell-lookup-documentation (cmd) + "Show help for CMD (a shell command or elisp function)." + (cond ((eshell-find-alias-function cmd) + (always (helpful-callable (eshell-find-alias-function cmd)))) + ((and (or (and (string-match-p "^\\*." cmd) + (cl-callf substring cmd 1)) + (eshell-search-path cmd)) + (zerop (car (doom-call-process manual-program cmd)))) + (always (display-buffer (man cmd)))) + ((functionp (intern cmd)) + (helpful-callable (intern cmd)) t) + ((user-error "Couldn't find man pages or elisp documentation for %S" cmd)))) + ;; ;;; Commands diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index a02bbf93b..2fc5eee4f 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -55,6 +55,9 @@ You should use `set-eshell-alias!' to change this.") ;;; Packages (after! eshell ; built-in + (set-lookup-handlers! 'eshell-mode + :documentation #'+eshell-lookup-documentation) + (setq eshell-banner-message '(format "%s %s\n" (propertize (format " %s " (string-trim (buffer-name)))