4 ms·
You can get similar behavior with bash's built-in history by setting a few options: # -------- History -------- #increase bash history HISTFILESIZE
by Evidlo 3y ago
You can get similar behavior with bash's built-in history by setting a few options:
# -------- History --------
#increase bash history
HISTFILESIZE=10000000
HISTTIMEFORMAT="%FT%R "
HISTSIZE=10000000
# append to .bash_history and reread after each command
export PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
# append to .bash_history instead of overwriting
shopt -s histappend
# dont allow repeated lines
export HISTCONTROL=ignoredups:erasedups
- geraldhh 3y agowondering if scanning throu >10M history entries, looking for duplicates, will introduce a noticeable ex degradation on lesser systems (rpi etc).
- znpy 3y agoThe file might fit without much problems in the filesystem cache, so i guess it would only be a problem in the first time. I had a friend in university that used a refurbished hp workstation with a shitload of ram as a desktop computer, and he would find | xargs -L1 cat {} > /dev/null everything in his home directory on login to warm up the filesystem cache. The kernel would then drop stuff not actually needed/accessed nicely over time.
- iforgotpassword 3y agoDon't know about erasedups, but the other option just applies to consecutive repeats, so really only had to scan from the end until the first non-dup
- deleted 3y ago[deleted]
- jefftk 3y agoExcept if you ever accidentally open a shell without those settings set (ex: "bash --norc" to get a clean profile) it will trim your decades-long history. Your HISTFILESIZE is also probably not enough: my .full_history goes back to 2012 and is 2.5x your limit.
- deleted 3y ago[deleted]
- everybodyknows 3y agoCuriously, I'm observing in bash 5.0-6ubuntu1.2 that tidily appending the above to the default ~/.bashrc does not work: The variables appear overwritten as intended when inspected, but upon shell exit, the first-set values (from first few lines of .bashrc e.g. HISTFILESIZE=2000) control the update to .bash_history. Anyone else see this in the bash distro? Seems to be a regression. The fix of course is to simply delete or hack a '#' into the start of the unwanted lines from the default .bashrc.