If you are accustomed (like me) to fire Ctrl+R
before running any new command, here is a tip to keep your Shell history clean and more search-friendly.
The best way to do this is to prevent some commands (e.g. those with passwords inlined) to be logged, but also to skip saving duplicated commands.
This is all controlled by the environment variable HISTCONTROL
. It can take 3 values:
ignorespace
: lines which begin with a space character are not savedignoredups
: lines matching the previous history entry are not savedignoreboth
: is shorthand for ignorespace and ignoredups
I recommend using ignoreboth
. One set, just start your commands with a space will to skip the shell history log.