【mac】设置命令行可以显示【项目名】【分支】
作者:互联网
1、 sudo vim ~/.bashrc
2、复制进去
function git_branch { branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`" if [ "${branch}" != "" ];then if [ "${branch}" = "(no branch)" ];then branch="(`git rev-parse --short HEAD`...)" fi echo " ($branch)" fi } BLACK=$(tput setaf 0) RED=$(tput setaf 1) GREEN=$(tput setaf 2) LIME_YELLOW=$(tput setaf 190) YELLOW=$(tput setaf 3) POWDER_BLUE=$(tput setaf 153) BLUE=$(tput setaf 4) MAGENTA=$(tput setaf 5) CYAN=$(tput setaf 6) WHITE=$(tput setaf 7) BRIGHT=$(tput bold) NORMAL=$(tput sgr0) BLINK=$(tput blink) REVERSE=$(tput smso) UNDERLINE=$(tput smul) export PS1='[dinglonggang@\[${CYAN}\]\W\[${GREEN}\]$(git_branch)\[${WHITE}\]] # '
3、sudo vim ~/.bash_profile
4、sudo vim ~/.bash_profile
标签:setaf,tput,命令行,sudo,vim,mac,git,branch,分支 来源: https://www.cnblogs.com/mailyuan/p/16581092.html