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

相關文章
相關標籤/搜索