emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Not clobbering bash history


From: Juri Linkov
Subject: Re: Not clobbering bash history
Date: Mon, 20 Nov 2023 19:50:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)

> Just as a complete aside for preventing bash history erasure, I got around
> it like this:
>
> * export HISTCONTROL=ignoreboth # I could also have used erasedups here but
> felt this would be unacceptably slow

Actually this is not quite off-topic.  In Emacs, the corresponding option
is 'history-delete-duplicates' that corresponds to 'ignoredups'.
But unfortunately still no option corresponding to 'ignorespace'.

Instead of using such advice

  (define-advice add-to-history (:around (ofun history-var newelt &rest args) 
ignorespace)
    (unless (string-match-p "\\` " newelt)
      (apply ofun history-var newelt args)))

maybe 'history-delete-duplicates' should support a new value 'ignorespace'?

> * export HISTSIZE=30000000
> # Yes, it's huge, but I get history going back years

I found that it helps to reduce the size of the shell history
by splitting the history file by different file trees using advice:

  (define-advice shell (:around (ofun &rest args) per-tree-history)
    (let ((process-environment (copy-sequence process-environment))
          (root (locate-dominating-file default-directory ".bash_history")))
      (when root
        (setenv "HISTFILE" (expand-file-name ".bash_history" root)))
      (apply ofun args)))

but no idea how this could be more customizable.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]