Bash History Tricks: big history, no duplicates, accesible from all the terminals

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
export HISTCONTROL=ignoredups:erasedups
# big big history
export HISTSIZE=100000
export HISTFILESIZE=100000
# append history entries
shopt -s histappend
# After each command, save and reload history
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"

Liked it? Take a second to support Geekster on Patreon!
Tagged with: , , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Support LinuxG via Patreon
Support LinuxG.net on Patreon!
Subscribe

  

Subscribe to get the latest Linux news and how to guides directly on your e-mail!