当前用户的配置

vim ~/.bashrc

全局用户的配置

vim /etc/profile

  1. vim ~/.bashrc
  2. #修改这段为:
  3. if [ "$color_prompt" = yes ]; then
  4. PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w$(git_branch)\[\033[00m\]\$ '
  5. else
  6. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(git_branch)\$ '
  7. fi
  8. # 在最后加上
  9. git_branch()
  10. {
  11. branch=`git rev-parse --abbrev-ref HEAD 2>/dev/null`
  12. if [ "${branch}" != "" ]
  13. then
  14. if [ "${branch}" = "(no branch)" ]
  15. then
  16. branch="(`git rev-parse --short HEAD`...)"
  17. fi
  18. echo -e " \033[1;35m{\033[1;33m$branch\033[1;35m}\033[0m " #颜色设置
  19. fi
  20. }
  21. # 执行脚本
  22. source ~/.bashrc