recentpopularlog in

Copy this bookmark:





to read

bookmark detail

Remember all your bash history forever | http://jesrui.sdf-eu.org/
WATCH OUT! Old-ass versions of Bash (4.1.x on CentOS 6, for example) will truncate your damn history file if you use HISTFILESIZE=-1 or HISTSIZE=-1.
Append the following lines to /etc/bash.bashrc:
<code class="language-bash">HISTTIMEFORMAT='%F %T '
HISTFILESIZE=-1
HISTSIZE=-1
HISTCONTROL=ignoredups
HISTIGNORE=?:??
shopt -s histappend # append to history, don't overwrite it
# attempt to save all lines of a multiple-line command in the same history entry
shopt -s cmdhist
# save multi-line commands to the history with embedded newlines
shopt -s lithist</code>

This configures bash to save every command line typed at the interactive shell prompt (HISTFILESIZE) to ~/.bash_history (default), including a timestamp (HISTTIMEFORMAT) and ignoring consecutive duplicate entries (HISTCONTROL). By setting HISTSIZE to the same value as HISTFILESIZE, all saved commands are read back to memory when a new interactive shell starts. The default value for HISTSIZE (500) would load only a fraction of the saved history.

When saving the history at shell exit, history lines are appended to existing ones, instead of replacing them (shopt -s histappend).

By setting HISTIGNORE=?:??, lines consisting of just one or two characters are discarded from the history (e.g. ls commands).
bash  history  tipsandtricks  configsettings  essential  movein  bashrc 
october 2018 by kme
view in context