function git-branch-name {
  git symbolic-ref --short -q HEAD 2>/dev/null
}
function git-branch-prompt {
  local branch=`git-branch-name`
  if [ $branch ]; then printf " [%s]" $branch; fi
}
PS1="\u@\h \[\033[0;36m\]\W\[\033[0m\]\[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\] \$ "

 

相关文章:

  • 2021-09-07
  • 2022-02-07
  • 2022-12-23
  • 2021-09-25
  • 2021-12-17
  • 2021-10-31
  • 2021-09-08
  • 2021-08-25
猜你喜欢
  • 2022-12-23
  • 2023-02-05
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2021-11-08
  • 2021-09-09
相关资源
相似解决方案