将.bash_profile文件中的内容复制到本地 ~/.bash_profile中即可。
如果你不想使用xxxxxxx:BranchName 的形式,你可以修改 parse_git_branch函数中的sed命令。
对sed命令第二个-e后面的字符串中的/:\1/部分进行修改。两侧的反斜杠是一个界限,不要修改,也不要在此之外做修改。\1代表着BranchName前后添加你希望添加的字符就可以(使用转义字符请自行参考sed命令)。这些字符在非git项目的目录是不会显示的。
| function parse_git_branch { | |
| git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/:\1/' -e 's/((/(/' -e 's/))/)/' | |
| } | |
| function proml { | |
| local LIGHT_RED="\[\e[1;37m\]" | |
| local RED="\[\033[1;32m\]" | |
| local COLOR_END="\[\e[0m\]" | |
| PS1="[\u@$LIGHT_RED\W$COLOR_END$RED\$(parse_git_branch)$COLOR_END]\$ " | |
| } | |
| proml |