标签:#Bash

Posts

· 2018-12-20 · * Bash *
Display Git Branch in bash prompt
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
}

export PS1='\[\033[34;34m\]\[email protected]\t\[\033[34;32m\] \w\[\033[00m\]\033[34m$(git_branch)\033[00m \$ '