On several occasions, I have lost some of my bash history, as the ssh session has not been exited cleanly. This annoyed me as I use the history as a means to remember what I have done. It prompted me to investigate if I could fix it and Unix being Unix, of course you can.
The History part of my .bashrc
file now looks like this;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth # append to the history file, don't overwrite it shopt -s histappend # BPO force all commands to be saved on one line shopt -s cmdhist # BPO append the command to the history after every command # prevents lost history when exit is not used PROMPT_COMMAND='history -a' # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=1000000 HISTFILESIZE=2000000 # BPO Save a time stamp # HISTTIMEFORMAT='%F %T ' # BPO Don't save common commands HISTIGNORE='ls:bg:fg:history' |
I tried adding a timestamp but that just looked messy so I took it out again.
HTH
by