Eshell: Remove duplicates in history
parent
4392607e8e
commit
368d2e3d8e
|
@ -201,7 +201,7 @@
|
||||||
;;; History
|
;;; History
|
||||||
;;; Filter out space-beginning commands from history.
|
;;; Filter out space-beginning commands from history.
|
||||||
;;; TODO: history/command hook: trim spaces. Check `eshell-rewrite-command-hook'.
|
;;; TODO: history/command hook: trim spaces. Check `eshell-rewrite-command-hook'.
|
||||||
;;; TODO: history: do not save failed Eshell commands (See `eshell-last-command-status')
|
;;; REVIEW: history: do not save failed Eshell commands (See `eshell-last-command-status')
|
||||||
;;; Eshell commands always return 0.
|
;;; Eshell commands always return 0.
|
||||||
(setq eshell-input-filter
|
(setq eshell-input-filter
|
||||||
(lambda (str)
|
(lambda (str)
|
||||||
|
@ -228,6 +228,17 @@
|
||||||
(setq eshell-history-ring ambrevar/eshell-history-global-ring))
|
(setq eshell-history-ring ambrevar/eshell-history-global-ring))
|
||||||
(add-hook 'eshell-mode-hook 'ambrevar/eshell-hist-use-global-history)
|
(add-hook 'eshell-mode-hook 'ambrevar/eshell-hist-use-global-history)
|
||||||
|
|
||||||
|
(defun ambrevar/eshell-history-remove-duplicates ()
|
||||||
|
"Remove duplicates of last command in history.
|
||||||
|
This should be faster then `seq-uniq'."
|
||||||
|
(let ((first (ring-ref eshell-history-ring 0))
|
||||||
|
(index 1))
|
||||||
|
(while (<= index (1- (ring-length eshell-history-ring)))
|
||||||
|
(if (string= first (ring-ref eshell-history-ring index))
|
||||||
|
(ring-remove eshell-history-ring index)
|
||||||
|
(setq index (1+ index))))))
|
||||||
|
(add-hook 'eshell-pre-command-hook 'ambrevar/eshell-history-remove-duplicates)
|
||||||
|
|
||||||
;;; Spawning
|
;;; Spawning
|
||||||
(defun ambrevar/eshell-or-new-session (&optional arg)
|
(defun ambrevar/eshell-or-new-session (&optional arg)
|
||||||
"Create an interactive Eshell buffer.
|
"Create an interactive Eshell buffer.
|
||||||
|
|
Loading…
Reference in New Issue