From 40b22bc70f62fda482e5354cebeebb4f2b732064 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 9 Oct 2021 16:21:46 -0500 Subject: Add eshell/z --- eshell.el | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/eshell.el b/eshell.el index c6078c2..a2ac33b 100644 --- a/eshell.el +++ b/eshell.el @@ -28,15 +28,32 @@ ;;; Functions +;; https://karthinks.com/software/jumping-directories-in-eshell/ +(defun eshell/z (&optional regexp) + "Navigate to a previously visited directory in eshell, or to +any directory proferred by `consult-dir'." + (let ((eshell-dirs (delete-dups + (mapcar 'abbreviate-file-name + (ring-elements eshell-last-dir-ring))))) + (cond + ((and (not regexp) (featurep 'consult-dir)) + (let* ((consult-dir--source-eshell `(:name "Eshell" + :narrow ?e + :category file + :face consult-file + :items ,eshell-dirs)) + (consult-dir-sources (cons consult-dir--source-eshell + consult-dir-sources))) + (eshell/cd (substring-no-properties + (consult-dir--pick "Switch directory: "))))) + (t (eshell/cd (if regexp (eshell-find-previous-directory regexp) + (completing-read "cd: " eshell-dirs))))))) + ;;; Extra eshell packages (setup (:straight esh-autosuggest) (:hook-into eshell-mode)) -(setup (:straight esh-help) - (require 'esh-help) - (setq-local eldoc-documentation-function #'esh-help-eldoc-command)) - (setup (:straight eshell-syntax-highlighting) (eshell-syntax-highlighting-global-mode +1)) @@ -53,3 +70,7 @@ (provide 'eshellrc) ;;; eshell.el ends here + +;; Local Variables: +;; flymake-inhibit: t +;; End: -- cgit 1.4.1-21-gabe81