From 8f8121e3a234185b739b87a7b11e0c0abce0e81c Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 2 Apr 2022 13:53:59 -0500 Subject: Add +eshell-here --- init.el | 2 ++ lisp/+eshell.el | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) 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") -- cgit 1.4.1-21-gabe81