1. function git-branch-name {
  2. git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3
  3. }
  4. function git-branch-prompt {
  5. local branch=`git-branch-name`
  6. if [ $branch ]; then printf " [%s]" $branch; fi
  7. }
  8. #PS1="\u@\h \[\033[0;36m\]\W\[\033[0m\]\[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\] \$ "
  9. PS1="[\u@\h \W] \[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\] \[\033[0;33m\]➜\[\033[0m\] "
  10. PS1="\[\033[0;33m\]➜\[\033[0m\] \[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\]
版权声明:本文为hanpengyu原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/hanpengyu/p/11250142.html