Posted: . At: 1:27 PM. This was 1 year ago. Post ID: 17937
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to have eternal bash_history on Linux if required.


This neat trick will enable an eternal bash history file, this could be very useful.

# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
# Force prompt to write history after every command.
# http://superuser.com/questions/20900/bash-history-loss
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"

This is an undocumented feature, but it will work great for storing all commands executed with the bash shell. Plus it forces the history to be written after each command. This will ensure that history is not lost in some circumstances.

Set the bash history time format.

export HISTTIMEFORMAT="%d/%m/%y %T "

This is in strftime format, this is an easy customization.

Set a certain value to the Xterm title bar, this is only for Xorg obviously.

# Setting the value of the Xterm title.
# Only if we are in X...
if [ $DISPLAY ] ; then
	PROMPT_COMMAND='echo -ne "\033]0;${OSRELEASE}: ${PWD}\007"'
fi

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.