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='[33[4;45m]u[33[00m]@h [33[01;36m]W[33[01;32m]$(git_branch)[33[00m]$ '
原文地址:https://www.cnblogs.com/liown/p/7383497.html