to remember all commands typed in multiple terminal 1

to remember all commands typed in multiple terminal

# Avoid duplicates
HISTCONTROL=ignoredups:erasedups
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend

# After each command, append to the history file and reread it
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"

Here is what the above code is Doing:
1. Set the history file location
2. Set the history size
3. Set the history timestamp format
4. Avoid duplicates
5. When the shell exits, append to the history file instead of overwriting it
6. After each command, append to the history file and reread it

Similar Posts