1. 程式人生 > >liunx多終端history命令實時同步

liunx多終端history命令實時同步

1. 顯示時間

export HISTTIMEFORMAT="%F %T  "

2. 顯示歷史命令條目數以及歷存放史命令檔案大小

HISTFILESIZE=100000
HISTSIZE=10000

3. 終端命令追加

# append to history, don't overwrite it
shopt -s histappend

4. 多終端實時同步

# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND
"

TODO

#### Avoid duplicates
export 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
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}
history -a; history -c; history -r"