Add +eshell-here

This commit is contained in:
Case Duckworth 2022-04-02 13:53:59 -05:00
parent abf24e71c7
commit 8f8121e3a2
2 changed files with 18 additions and 0 deletions

View File

@ -342,6 +342,8 @@
eshell-prompt-regexp (rx bol (* (not (any ?# ?$ ?\n))) eshell-prompt-regexp (rx bol (* (not (any ?# ?$ ?\n)))
" " (any ?# ?$) " " (any ?# ?$)
(* " "))) (* " ")))
(:+leader "s" #'+eshell-here
"C-s" #'+eshell-here)
(with-eval-after-load 'mwim (with-eval-after-load 'mwim
(setf (alist-get 'eshell-mode mwim-beginning-of-line-function) (setf (alist-get 'eshell-mode mwim-beginning-of-line-function)
#'eshell-bol)) #'eshell-bol))

View File

@ -25,6 +25,22 @@ any directory proferred by `consult-dir'."
;;; Start and quit ;;; 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) (defun +eshell-quit-or-delete-char (arg)
"Delete the character to the right, or quit eshell on an empty line." "Delete the character to the right, or quit eshell on an empty line."
(interactive "p") (interactive "p")