vim /etc/profile
##添加以下内容到末尾
export HISTTIMEFORMAT="[%Y-%m-%d %H:%M:%S] [`who am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`] " echo "" > .bash_history export PROMPT_COMMAND='if [ -z "$OLD_PWD" ];then export OLD_PWD=$PWD; fi; if [ ! -z "$LAST_CMD" ] && [ "$(history 1)" != "$LAST_CMD" ]; then logger -t `whoami`_shell_cmd "[$OLD_PWD]$(history 1)"; fi ; export LAST_CMD="$(history 1)"; export OLD_PWD=$PWD;'
source /etc/profile
注意:修改后再打开窗口会清除之前的命令记录,history只保留新开窗口的记录。