Bash – Keep all commands in bash history

bashcommand history

I have the opposite question to this. How do I keep all commands in bash history?

In Ubuntu since quite some time now, the default for bash is to forget commands with non success exit code.

Unix user @goldilocks pointed out that maybe I am just confused by the ignoreboth directive.

set pastie

Best Answer

FWIW, I use HISTFILE=~/.bash_history_$(date '+%Y%m%d_%H_%M_%S_%N').txt in my .bashrc file to make a single history file for each session, with a timestamp. That way I don't lose commands when I hit $HISTSIZE commands. history only shows me the command history for the current terminal session, but I can easily search previous bash history with grep 'what to find' .bash_history*

Related Question