Last active
December 12, 2015 04:28
-
-
Save chrisbraddock/4714691 to your computer and use it in GitHub Desktop.
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
# http://hocuspokus.net/2009/07/add-git-and-svn-branch-to-bash-prompt/ and http://railstips.org/blog/archives/2009/02/02/bedazzle-your-bash-prompt-with-git-info/ | |
parse_git_branch () { | |
#git name-rev HEAD 2> /dev/null | sed 's#HEAD\ \(.*\)# (git::\1)#' | |
#git branch 2> /dev/null | grep "" | sed -e 's/*//g' | |
#git branch 2> /dev/null| sed -n '(^\*/s/^\* //p' | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo " (git::"${ref#refs/heads/}")" | |
} | |
# detect whether any changesets are stashed | |
# from: https://raw.github.com/mgax/git-sh/0326321b27e17bc7db02786ae2abe74e50a40e6f/git-sh.bash | |
git_dirty_stash() { | |
if ! git rev-parse --verify refs/stash >/dev/null 2>&1; then | |
return 0 | |
fi | |
echo "*" | |
} | |
export PS1="$BLACK[ \u@$RED\h $GREEN\w$RED_BOLD\$(parse_git_branch)\$(git_dirty_stash)$BLACK ] " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment