Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A git aware bash prompt for ubuntu, that shows what branch you are on, and whether you have anything to commit. Add to your .bashrc file. Works with git version 1.7.9.5. Initially taken from http://www.intridea.com/blog/2009/2/2/git-status-in-your-prompt
# A git aware bash prompt for ubuntu, that shows what branch you are on, and whether you have anything to commit.
# Add to your .bashrc file.
# Works with git version 1.7.9.5.
#
# Based on http://www.intridea.com/blog/2009/2/2/git-status-in-your-prompt
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]$(parse_git_branch)$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.