编辑 .bash_profile 文件
1 2 3 4 5 6
|
vi .bash_profile
touch .bash_profile vi .bash_profile
|
将下列代码复制粘贴到 .bash_profile 的末尾,保存后重启终端即可。
1 2 3 4 5 6 7 8 9 10 11 12
|
function git_branch { branch="git branch 2>/dev/null | grep "</span>^*<span class="string">" | sed -e "</span>s/^* //<span class="string">" " if [ "${branch}" != "" ];then if [ "${branch}" = "(no branch)" ];then branch="(git rev-parse --short HEAD ...)" fi echo " ($branch)" fi } export PS1='[email protected] [ 33[01;36m]W[ 33[01;32m]$(git_branch)[ 33[00m] $ '
|
显示效果
近期评论