Eternal History File

Eternal History File

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
cat << EOF | sudo tee /etc/profile.d/eternal-history.sh
# set unlimited history
export HISTFILESIZE=
export HISTSIZE=

# add timestamp to history
export HISTTIMEFORMAT="%F %T » "

# use different file as sometimes .bash_history gets truncated
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.eternal_history

# Preserve bash history in multiple bash shells?

# remove duplicates
export HISTCONTROL=ignoredups:erasedups

# appending a on exiting session vs rewriting is turned on by default 
# shopt -s histappend

# force prompt to write history after every command.
# simplest version: after each command, append to the history file and reread it
# "-a" history to file, "-c" clears history, "-r" reads history from file
PROMPT_COMMAND="history -a; history -c; history -r"
EOF

Shared history bash - Is it possible to make writing to .bash_history immediate? - Ask Ubuntu

date 14. Mar 2021 | modified 03. Feb 2023
filename: Command Line » Eternal History
Article Content