History completion in eshell
This commit is contained in:
parent
11efc745e3
commit
10946e39ae
1 changed files with 22 additions and 1 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue