Created
December 10, 2014 12:00
-
-
Save rafacouto/fd44c40dbab1d6aed80a to your computer and use it in GitHub Desktop.
Sets a prompt showing the git branch when within a git directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git prompt | |
function git-branch-name { | |
git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3 | |
} | |
function git-branch-prompt { | |
local branch=`git-branch-name` | |
if [ $branch ]; then printf " [%s]" $branch; fi | |
} | |
PS1="\u@\h \[\033[0;36m\]\W\[\033[0m\]\[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\] \$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment