public
Created

This gist allows to prompt current Git branch as part of your shell prompt

  • Download Gist
.profile
Shell
1 2 3 4 5 6 7 8 9 10 11 12
# add this into .profile, .bash_profile or .bash_rc
# This function gets current git branch
function parse_git_branch {
brs=$(git branch 2>/dev/null | grep '^*' | colrm 1 2) || return
if [ -z "$brs" ]
then echo ""
else echo "‚Ć• $brs"
fi
}
 
# PS1 with git branch
PS1="\u@\h: \W\$(parse_git_branch)\$ "

Here is what I have: MrCloud@CloudServer: GitProject‚Ć•develop$

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.