解決CentOS終端命令不同步問題

history(){
  syncHistory
  builtin history "$@"
}

syncHistory(){
  builtin history -a
  HISTFILESIZE=$HISTFILESIZE
  builtin history -c
  builtin history -r
}

promptCommand(){
  if [ "$TERM" = xterm ]
  then case "$DISPLAY" in
       :*)  printf "\033]0;%s\007"                     "$PWD" ;;
       *)   printf "\033]0;%s -- %s\007" "$HOST_UPPER" "$PWD" ;;
       esac
  fi
  syncHistory
}

HOST_UPPER=`echo $HOSTNAME | tr '[a-z]' '[A-Z]'`
PROMPT_COMMAND=promptCommand

貼在.bashrc即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章