ubuntu shell显示git branch

ubuntu shell显示git branch

.bashrc文件中加入:git

black=$'\[\e[01;30m\]'
    red=$'\[\e[01;31m\]'
  green=$'\[\e[01;32m\]'
  yello=$'\[\e[01;33m\]'
   blue=$'\[\e[01;34m\]'
magenta=$'\[\e[01;35m\]'
   cyan=$'\[\e[01;36m\]'
  white=$'\[\e[01;37m\]'
 normal=$'\[\e[m\]'
#. /usr/lib/git-core/git-sh-prompt
if [ "$color_prompt" = yes ]; then
        PS1="${debian_chroot:+($debian_chroot)}$green\u@\h$yellow:$blue\w$normal\$$red"'$(__git_ps1 " (%s)")'"$normal "
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

其中前面时设置控制台色彩,后面PS1的部分是调用了__git_ps1 函数shell

相关文章
相关标签/搜索