Eshell C-d to exit

This commit is contained in:
2025-06-21 22:10:48 -07:00
parent 8c6fccb87d
commit 6ec43a8375

View File

@@ -968,12 +968,28 @@ the new eshell window is selected."
(select-window new-window) (select-window new-window)
(let ((default-directory starting-dir)) (let ((default-directory starting-dir))
(eshell t)))) (eshell t))))
; (select-window new-window)))
(defun my/eshell-delete-char-or-exit ()
"In Eshell, exit if at an empty prompt, otherwise delete a character."
(interactive)
;; Check if the cursor is at the end of the buffer AND right after the prompt marker.
;; This is the condition for being on a clean, empty prompt.
(if (and (eobp)
(save-excursion
(let ((orig (point)))
(beginning-of-line)
(= (point) orig))))
(progn
(kill-this-buffer)
(when (not (one-window-p))
(delete-window)))
(delete-char 1)))
(use-package eshell (use-package eshell
:bind (("M-`" . my/eshell-toggle) :bind (("M-`" . my/eshell-toggle)
:map eshell-mode-map :map eshell-mode-map
("C-S-<return>" . my/split-largest-eshell-and-focus)) ("C-S-<return>" . my/split-largest-eshell-and-focus)
("C-d" . my/eshell-delete-char-or-exit))
:config :config
(setq eshell-destroy-buffer-when-process-dies t (setq eshell-destroy-buffer-when-process-dies t
eshell-scroll-to-bottom-on-input t eshell-scroll-to-bottom-on-input t