diff --git a/init.el b/init.el index 3c1d975..84b3869 100644 --- a/init.el +++ b/init.el @@ -342,6 +342,8 @@ eshell-prompt-regexp (rx bol (* (not (any ?# ?$ ?\n))) " " (any ?# ?$) (* " "))) + (:+leader "s" #'+eshell-here + "C-s" #'+eshell-here) (with-eval-after-load 'mwim (setf (alist-get 'eshell-mode mwim-beginning-of-line-function) #'eshell-bol)) diff --git a/lisp/+eshell.el b/lisp/+eshell.el index bcab846..b874141 100644 --- a/lisp/+eshell.el +++ b/lisp/+eshell.el @@ -25,6 +25,22 @@ any directory proferred by `consult-dir'." ;;; Start and quit +;; from https://old.reddit.com/r/emacs/comments/1zkj2d/advanced_usage_of_eshell/ +(defun +eshell-here () + "Go to eshell and set current directory to current buffer's." + ;; consider: make a new eshell buffer when given a prefix argument. + (interactive) + (let ((dir (file-name-directory (or (buffer-file-name) + default-directory)))) + (eshell) + (eshell/pushd ".") + (cd dir) + (goto-char (point-max)) + (eshell-kill-input) + (eshell-send-input) + (setq-local scroll-margin 0) + (recenter 0))) + (defun +eshell-quit-or-delete-char (arg) "Delete the character to the right, or quit eshell on an empty line." (interactive "p")