Skip to main content

Preserving Linux Shell History Even If Working with Multiple Terminals

If you are continuously running shell commands on more than one linux terminal, probably you want all of the shell (mostly bash) prompts to remember any command from any terminal. With the following environmental variables to save the .bashrc file, you can do it so.

# This is for ignoring duplicate entries
export HISTCONTROL=ignoredups:erasedups

# This is for large history
export HISTSIZE=102400

# This is for a big history file
export HISTFILESIZE=100000

# This is for appending commands to history file
shopt -s histappend

# This is for saving and reloading the history after each command is run
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"


Popular posts from this blog

Find and replace with sed command in Linux

Find and replace feature is always handy. It can turn into a torture when it comes to change or delete a simple constant string in a text file. There is a handy tool in linux for doing these kind of tihngs. Actually sed is not a text editor but it is used outside of the text file to make changes.