diff options
| author | bh <qn+git@excalibur.computer> | 2025-12-19 21:12:08 +0800 |
|---|---|---|
| committer | bh <qn+git@excalibur.computer> | 2025-12-19 21:12:08 +0800 |
| commit | 70e917d344f92c712a5b812ece5fa1a30a8eb687 (patch) | |
| tree | cd3de6965a3ca322eaca74bfba329edb2dd60fa2 /config/eshell.el | |
| parent | 570488ecfb703fa00b5d45e541f17657114b8b03 (diff) | |
Fixed C-d in eshell
Diffstat (limited to 'config/eshell.el')
| -rw-r--r-- | config/eshell.el | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/config/eshell.el b/config/eshell.el index 02ea970..740c560 100644 --- a/config/eshell.el +++ b/config/eshell.el @@ -12,6 +12,14 @@ eshell-kill-processes-on-exit t eshell-hist-ignoredups t) +;; Function to make C-d exit eshell (from Doom Emacs) +(defun my-eshell-quit-or-delete-char (arg) + "Delete a character (ahead of the cursor) or quit eshell if there's nothing to delete." + (interactive "p") + (if (and (eolp) (looking-back eshell-prompt-regexp nil)) + (eshell-life-is-too-much) + (delete-char arg))) + ;; History settings (setq eshell-history-size 100000 eshell-history-file-name (concat user-emacs-directory "eshell/history") @@ -188,14 +196,9 @@ ;; Emacs-style line navigation (define-key eshell-mode-map (kbd "C-a") 'eshell-bol) (define-key eshell-mode-map (kbd "C-e") 'end-of-line) - ;; C-d exits if line is empty, otherwise deletes character - (define-key eshell-mode-map (kbd "C-d") - (lambda () - (interactive) - (if (and (eolp) (looking-back eshell-prompt-regexp nil)) - (eshell-life-is-too-much) ;; Exit eshell - (delete-char 1))))) ;; Delete character - )) + ;; C-d exits eshell or deletes char (Doom Emacs implementation) + ;;(define-key eshell-mode-map (kbd "C-d") 'my-eshell-quit-or-delete-char))) + (define-key eshell-mode-map (kbd "C-d") 'eshell-life-is-too-much))) ;; ===================================== ;; Evil Integration @@ -205,6 +208,9 @@ ;; Start in insert mode (like terminal) (add-to-list 'evil-insert-state-modes 'eshell-mode) + ;; Bind C-d in evil insert state for eshell + (evil-define-key 'insert eshell-mode-map (kbd "C-d") 'my-eshell-quit-or-delete-char) + ;; Add eshell to evil-collection if available (with-eval-after-load 'evil-collection (evil-collection-eshell-setup))) |
