summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-12-07 12:00:13 +0000
committerSean Whitton <spwhitton@spwhitton.name>2023-12-07 12:00:13 +0000
commit038bfd1930dbb8385da2dacdef40390c1938d6f9 (patch)
tree226c6fe3141af9059170041982fbaccfd6b8685f
parenta2f5b830645e48ea10f0d418942eb32e97cb8c23 (diff)
downloaddotfiles-038bfd1930dbb8385da2dacdef40390c1938d6f9.tar.gz
use new eshell-history-append, set eshell-hist-ignoredups
-rw-r--r--.emacs.d/init.el42
1 files changed, 5 insertions, 37 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index b388ba67..3b3b8e0e 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -227,7 +227,10 @@ windows side-by-side in the frame."
'(enable-recursive-minibuffers t)
'(eshell-cmpl-cycle-completions nil nil nil "This makes Eshell completions a bit more like bash's.")
'(eshell-cmpl-ignore-case t)
+ '(eshell-hist-ignoredups 'erase)
+ '(eshell-history-append t)
'(eshell-history-size 5000)
+ '(eshell-save-history-on-exit nil)
'(eshell-visual-commands
'("vi" "screen" "tmux" "top" "htop" "less" "more" "mutt" "locmaint" "gen-DSA"
"gen-DLA" "gen-ELA"))
@@ -1654,45 +1657,10 @@ the non-side windows deleted by `delete-other-windows' will also reappear."
;;;; The Emacs shell
-;; This is like HISTCONTROL=ignorespace:ignoredups and 'shopt -s histappend'
-;; in my ~/.bashrc: append most commands to the shared history file, but don't
-;; load that file except when a fresh Eshell buffer is created.
-(setq eshell-save-history-on-exit nil)
-(defun spw/eshell-append-history ()
- (when (and eshell-history-file-name
- (symbolp (file-locked-p eshell-history-file-name)))
- (unless (get-buffer " *eshell history*")
- (lock-file eshell-history-file-name)
- (with-current-buffer (get-buffer-create " *eshell history*" t)
- (when (file-exists-p eshell-history-file-name)
- (insert-file-contents eshell-history-file-name))))
- (let ((latest (substring-no-properties (ring-ref eshell-history-ring 0))))
- (with-current-buffer (get-buffer " *eshell history*")
- (let* ((nlines (car (buffer-line-statistics)))
- (excess (- nlines eshell-history-size))
- (previous
- (and (cl-plusp nlines)
- (save-excursion
- (goto-char (1- (point-max)))
- (buffer-substring (point-at-bol) (point-at-eol))))))
- (unless (or (string-match "^\\s-" latest)
- (and previous (string= previous latest)))
- (unless (cl-minusp excess)
- (forward-line (1+ excess))
- (delete-region (point-min) (point)))
- (save-excursion
- (goto-char (point-max))
- (let ((start (point)))
- (insert latest "\n")
- (subst-char-in-region start (1- (point)) ?\n ?\177)))
- (write-region (point-min) (point-max) eshell-history-file-name nil
- 'silent)))))))
(with-eval-after-load 'esh-cmd
- (add-hook 'eshell-pre-command-hook #'spw/eshell-append-history))
-(with-eval-after-load 'esh-mode
- (add-hook 'eshell-mode-hook
+ (add-hook 'eshell-pre-command-hook
(lambda ()
- (remove-hook 'eshell-exit-hook #'eshell-write-history t))))
+ (eshell-write-history nil eshell-history-append))))
;; We could have an optional argument to kill any input and reinsert it after
;; running the command, and even restore point within that input. Might be