In this article I will show you some bash history magic. With the following settings added in your ~/.bashrc file, you will make your history:
- Remember everything from every terminal
- Is instanly accesible from every terminal
- Doesn’t skip random commands if there are spaces at the front of the commands
So, if you are that guy that always has more than 3 terminals open, after you add these lines in your ~/.bashrc file no command will be forgotten from your history, and you will be able to ls in one terminal and than press the up arrow on another runnig terminal and get your ls command.
# avoid duplicates
# big big history
# append history entries
shopt -s histappend
# After each command, save and reload history
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"