shell 提示符个性化设置

提示符具体含义可参考: http://billie66.github.io/TLCL/book/zh/chap14.html

Ubuntu16.04个人配置如下,供以后查阅

 1 function git_branch {
 2    branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`"
 3    if [ "${branch}" != "" ];then
 4       if [ "${branch}" = "(no branch)" ];then
 5          branch="(`git rev-parse --short HEAD`...)"
 6       fi
 7       echo " ($branch)"
 8    fi
 9 }
10 export PS1='\[\033[4;45m\]\u\[\033[00m\]@\h \[\033[01;36m\]\W\[\033[01;32m\]$(git_branch)\[\033[00m\]\$ '

 

posted @ 2017-08-17 18:13  liown  阅读(303)  评论(0编辑  收藏  举报