History completion in eshell
Some checks failed
EVAL x86_64-linux.picard
BUILD x86_64-linux.picard
UPLOAD x86_64-linux.picard
DOWNLOAD x86_64-linux.picard
CACHIX x86_64-linux.picard
ATTIC x86_64-linux.picard
/ test (push) Successful in 7m53s

This commit is contained in:
Andrea Ciceri 2025-04-24 14:06:15 +02:00
parent 11efc745e3
commit 10946e39ae
No known key found for this signature in database

View file

@ -690,9 +690,30 @@
(defalias (car alias) (cdr alias))) (defalias (car alias) (cdr alias)))
ccr/eshell-aliases) ccr/eshell-aliases)
(defun ccr/eshell-get-current-input ()
(when (eq major-mode 'eshell-mode)
(let ((input-start (save-excursion
(eshell-bol)
(point)))
(input-end (point-at-eol)))
(buffer-substring-no-properties input-start input-end))))
(defun ccr/eshell-history ()
(interactive)
(when (eq major-mode 'eshell-mode)
(let* ((current-input (ccr/eshell-get-current-input))
(eshell-history (f-read-text eshell-history-file-name))
(bash-history (f-read-text "/home/ccr/.bash_history"))
(history (split-string (concat eshell-history "\n" bash-history) "\n"))
(selection (completing-read "History: " history nil t current-input)))
(eshell-bol)
(kill-line)
(insert selection))))
:bind (("C-c o e" . project-eshell) :bind (("C-c o e" . project-eshell)
(:map eshell-mode-map (:map eshell-mode-map
("C-r" . eshell-atuin-history) ("C-r" . ccr/eshell-history)
("C-<return>" . corfu-send) ("C-<return>" . corfu-send)
))) ;; i.e. just C-r in semi-char-mode ))) ;; i.e. just C-r in semi-char-mode